Creating a Ledge Grab System (part 4)
The trick about pulling your character up the ledge is that your character ISN’T pulling your character up physically. Technically playing an animation to simulate the action and feeling, but the root body collider is actually teleporting from the ledge to the top of the platform.
Setting Up the Pull:
As usually, we need to download the proper animation which we can grab quickly thanks to Mixamo.
Import and assign the newly downloaded animation into the Animator. We are going to create a new transition from hanging to climbing.
For this animation clip we also need to adjust some settings in the Inspector before we apply it to our Animator. We need to check on the “Root Transform Rotation” and also “Root Transform Position (y) along with “Root Transform Position (XZ). This is to make sure that the animation does indeed increase in height even thought our player collider won’t be moving.
To quickly test this new animation we are going to set up an Trigger Parameter so during scene play, we can toggle the animation manually.
In the player script, we need to refine the current setup for the hanging toggle. During the hanging animation, our parameters for “Jumping” and “Speed” are set incorrectly, therefore it might cause unwanted confusion in the next state transition.
Therefore in the public Ledge Grab method, we need to hard code the parameters to be set false and the speed to zero.
Also in the Unity Animator conditions, select the transition between Jumping and Idle because we need to add in another condition which is LedgeGrab and the setting should be set to “False”. That way the Jumping animation would go straight to hanging animation if Ledge grab is true.
Now when we play test the scene, we can manually toggle the climb up animation when we are hanging.
In the next article we will finally finish off with the teleportation of the character controller/collider to the top of the platform and also work with Animations Events.