Climb Up With Animation Event- Game Dev Series 90

S.J. Jason Liu
3 min readJul 25, 2021

Objective: create the function of climb up from ledge with gameobject reposition.

After we successfully grabbing on the ledge, the next part we need to finish is to climb up that platform.

In this article, we will make Player climb up that platform to complete this action.

The main issue

When you download the climb up animation and import it to Player, you might notice that animation model and Player gameobject has pulled apart when the animation got played.

To make a perfect climb up action, we need to reposition the Player gameobject to where we climbed up after the motion of this animation.

Setting the animation behavior

The concept of climb up the ledge is after the animation played, Player should stand up the platform and idling.
We need to check if the climb up animation has finished playing. To do this part, we can use animation state behavior.

Select the animation in Animator, and click Add Behavior in Inspector. Create a script by giving the name on your own.

Inside this script, it would be like this.

There are 5 default method of this script. These are the methods that would proceed during this animation state.

In here we would use OnStateExit(). Get the reference of Player script as preparation.

Once we get the Player script, we can create a public method in Player to complete the climbing.

After climb up

Create a public method in Player. This would be called from Climb Up animation state. In this method, we should enable the CharacterController, and also reposition Player.

Then we need to get a new position after the motion. As we set the grabbing position in the previous article, set a new Vector3 as stand up position to Player.

Inside Ledge script, create a new Vector3 variable.

And return this position in a public method.

However, there is no reference of Ledge script in Player. We need to receive one from GrabLedge() method. Create a variable and add another requirement to GrabLedge() method.

We need to pass in the requirement in Ledge script.

Then we should be able to use the public method in Ledge to update position.

Now we can back to animation state behavior script to complete it!

All done! When Player is climbing up the platform, it should stand up at its current position!

--

--

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.