Objective: Create an Animation Event for the Player to Climb Up
Following on, we have our Player hanging from the ledge. We need to get him to climb up on a button click but first we need to find an appropriate climb up animation to transition with. We go to Mixamo and source the animation.
After finding the above animation, we download, import, set the rig to humanoid, duplicate and move the copy into our animations folder.
As you can see above we have a slight issue. When the Player has climbed up and switched to idle state the Player ends up back down where he switches to hanging state. This is because the animation moves the Player but the collider and objects within the Player aren’t moving with the Player and animation(shown below). We need the Player to end up in position at the end of climbing up.
To fix this we will add an behaviour animation script. We add an onledge bool to the Player and set it to true when the Player has grabbed the ledge. In Update we check for if on ledge then if true check an input of the E key before triggering the climb up transition. We create a public ClimbComplete method which will be called from the ClimbUpBehaviour scripts OnStateExit method.
Inside the ledge script we add a new Vector3 fot standing position. This will be the position for the idle state after the climb up instead of the Player dropping back to the hanginf position shown earlier. We create a public Vector3 helper method to return the private Vector3 values from the standing position. This is called from the Climb Complete method and sets the Players position, turns off the Animator GrabLedge bool parameter and re-enabled the CharacterController.
The transition between the climb up and idle is a bit snappy but this will be fixed later with a stand up animation transition between the two.