2.5D Platformer — #11 Climbing Ledge
Objective: Give the character climb ledge ability
In the last article, we gave the character the ability to grab onto a ledge after jumping across. In this article, we will give the character the ability to climb onto the ledge.
Import a Climbing a Ledge Animation
Firstly we will head over to the Mixamo website, find and download the animation we require for this ability.
Drag the downloaded FBX file into Unity and extract the animation file (see the previous article on how to do this).
Configure the animation
Drag on the Climbing animation into the Character Animator Controller. Create a Trigger and wire it up to the Transition from the Hanging to Climb.
For this animation, Bake Into Pose for Root Transform settings.
With the animation and the parameter setup, lets call this trigger and it makes sense when the character is hanging to press W to climb up.
If we are to press Play and make the character climb, it does what it is suppose to do but the character ends up at the bottom.
The reason this occurs is the animations moves the “skin” of the character to the top of the ledge but the character controller still remains at where the character was hanging. Click on the character in the scene view to see where the Character Controller remains.
We need to move the Character Controller to where we want to Idle animations to occur after the climb has completed and how can we do this?
Lucky for us, animations can execute scripts at certain stages of the animation. In this case, we will create a script that executes when the exits the Climb animation.
Create a ClimbUpBehaviour script
Create the script.
In the Player script, we have a public method that positions the Character Controller in the standing position supplied by theLedge script.
That is all we need to do now to make the character appear on the platform.
If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.
I am available for your next chart-topping game!