Using Animation Events in Unity
Objective: Get the player onto the top platform after the climb-up animation.
Setting the Standing Position
The animation we are using uses root motion to move the player model. This does not move the player colliders and if you were to go to idle the player would go back to the stop he was hanging at.
To fix this we will use the standing position mentioned in my last article and line it up with the model's feet on top of the platform.
Make sure you have the stand position set in the ledge grab script created in the last article.
On the climb-up animation, click the add behavior button and add a script to control the animation behavior.
Before adding code to the behavior script go to the ledge grab script and create a new public method. This method will return the transform of the standing position.
In the player script, create a new public method that will activate the character controller, set the player's position to the standing position, and resets the values for the animations.
In the behavior script, look for the OnStateExit method. This will allow code to run when the animation ends. Create a reference to the player script and call the method that you just made in the player script.
Create a transition from the climb-up animation to the idle animation. Has exit time should stay on and the transition duration should be 0. Turn of the fixed duration.
This will bring the player to the top platform.