Using Animation Events in Unity

We pick up right where we left off, hanging from our ledge.
Now we have to make the effort that will allow us to ascend the platform to which we are hanging on.

In a swaggering way, we think that we just need to go to Mixamo.com to find a suitable animation and that’s it.

Unfortunately, it’s not enough, that’s what happens if we limit ourselves to animation.

As with the hands, we need to know the final position of our player and move it instantaneously, this is because of using root motion. The animation does not affect the real displacement of our model.

But we need a way to understand when the animation ends and just at that moment call a method that fixes everything.

Obviously in Unity is possible, there is a kind of script with a lot of methods already commented on and ready to use.

We can create this script directly inside the animations that we have in the Animator Tab. This class that we are creating inherits from “StateMachineBehaviour” and has 5 methods that we can use as we like. As said before we are interested in modifying the position of our Player collider at the end of the Climb animation.

In the “OnStateExit” method we call the ClimbUp method written in the player class and test everything.

project manager by day, unity developer by night