In this video, we're going to design
the walls push animation which should look like this.
It's going to have a slight delay at the start
so that when the player enters the area, they have a bit of time to stop
or to move in front of the wall and get pushed.
Then it's going to have a fast push with an easing.
It's going to stay in position for a fraction of a second,
and then slowly move back to its start position.
With that, let's get started.
With the push wall scene open,
we'll start by selecting the PushWall root node
and press CTRL-A to add a new animation player node as a child of it.
The first thing we want to do is head to the Inspector
and change the Playback Options Process Mode from Idle to Physics.
The Physics Process mode ensures that the animation
synchronizes with Goodhouse physics updates,
allowing the animation to properly collide with the player.
We're going to go down to the Animation bottom panel
and we'll click the Animation menu, New,
and create a new animation called Push Down,
and we're going to Zoom in on the timeline
in the bottom right of the animation editor
just to have a bit more room to edit our animation.
Now, we want to select the StaticBody2D node,
which is what we're going to animate,
we're going to animate it moving down, then back up.
In the Inspector, you want to expand the Transform category
and we're going to click the key next to Position to create a new keyframe.
So click it.
You should see this confirm window, you can click Create, keep the default.
And this is going to start the animation here.
So at first, we want the node not to move.
We're going to move the time cursor to 0.1 second
so you can click and drag on the gray area to do so.
Then select the first keyframe, right-click, and duplicate this one.
This is going to keep the wall in place for 0.1 second.
You can move this key to the right to increase that time delay.
This will be the time the player has
to either stop in front of the wall or pass through.
The 0.1 second should be reasonable.
Then, we're going to automate the wall pushing down
so we want to move the time cursor forward to 0.3 seconds.
And then we can again right-click the last key and select Duplicate.
It's going to keep it the same.
Now, we can click that new key to select it,
and we're going to change the Y value in the Inspector to 128 pixels.
If you then click and drag on the animation timeline,
it's going to move the wall down
and you can press Shift-D to play your animation.
We're going to keep the wall in place for 0.2 seconds.
So select the last keyframe, right-click Duplicate,
and finally we are going to have it move back to the start position
so we can move the time cursor to the end of the animation timeline.
Select one of the first keyframes, right-click Duplicate.
And if you play the animation with Shift-D now,
you're going to see the wall push down, wait, and go back.
Now, the animation is a bit robotic.
This is due to the lack of animation Easings.
We're going to change those to make our animation a bit more natural.
So select the second key.
And in the Inspector, you can see the Easing curve.
It's a field on which you can click and drag to the right or drag to the left
to change the animation transition. I invite you to play a bit with it.
You can drag it a bit to the right
and then press shift-D to see the animation.
and you can see now the wall accelerates down
and it gives you a bit more of a push.
So a value around two or above two should work.
And then we're going to click the key, add 0.5 seconds after the wall pushed
before it starts going back, and we're going to do the opposite.
We're going to drag the curve a bit to the left.
And this is going to make the wall slow down
as it arrives to its starting position.
And if you want, you can also drag it a bit to the right
and have it go back a bit more slowly.
Actually, it feels a bit better to me.
So I think we're going to keep it that way.
You now have your push animation done.
But for now, it's not going to interact with the player
because we are lacking the code to do so.
We'll add that in the next lesson. See you there.