Journal 82 — Unity 2.5D Platformer, Implement the Climb Up

Chris Nielsen
3 min readSep 1, 2021

Objective: Go from a hanging ledge to climb up off the ledge.

In the previous journal, we completed the hanging ledge function of our platformer. In this journal, we will finish the game sequence by climbing up from the ledge and standing up, ready to continue.

Let’s add a climb up animation from Mixamo.

We can import this animation into Unity, set to “Humanoid”, and duplicate the animation so it is editable.

When grabbing the ledge, we also want to turn off speed and jumping, so the player cannot inadvertently transition to another state.

Fix Climb Up

We need to fix the climb up implementation. The player game object is still hanging from the ledge. An animation of the player climbing up played, but that does not affect the player’s location. We want to capture the location of the climb up position and essentially teleport the player to that spot, and show the idle animation.

In the Animator window, we can add a behaviour to the Climbing animation.

In the animation behaviour script, we can remove the comment marks for OnStateExit, and we need to reference the Player class in order to play the idle animation after the climbing animation.

We can add code so that pressing the ‘e’ key will trigger the climb up animation.

Let’s make a duplicate player to figure out the position to stand up after climbing the ledge.

Now we need to update the ledge script to have a reference to the correct standing position.

In the climb up animation behaviour script, we can get a reference to the animator which is on a child of the player, and call a new method after the climb up animation is complete.

In the player script, we can make the ledge grab modular with a reference to the current ledge, such as if we use the same code at a different ledge. We can also fill out the method we created after climbing up by fixing the player’s position to the correct standing position, and re-enable the character controller.

Finally we can see the results.

Thank you for your time!

--

--

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.