GameDevHQ Crash Course #22 Animation Triggers
Stealth Game & Cinematography-Animation Triggers
Last time we got our capsule to move around the scene with mouse clicks. This time we have replaced that capsule with a character model
Our model here comes with a bunch of animations that we are going to use for this scene. first is obviously a moving animation, as amusing as sliding around would be, not what we are going for here, so we need to link some animations together to get something smooth and coherent.
So first we make ourselves a player animation controller, that will be what we will use to put all the animations and their triggers together, unities animation controller gives us this nice visual layout so we can see what possible animations we have linking to each other. First we have our idle pose, that will be the default pose that we get when we are nothing clicking anywhere and the default pose we want our player to go back to once they reach their destination or finish throwing a coin, so we set that up to be the animation that plays once we have the character enabled, then using a bool with our code we then trigger our walk animation once the character has a destination hit by our raycast click.
We could use a trigger for our coin but I have set a coroutine that lasts just under the animation duration of the throw animation that locks the player in place to throw the coin, then resets the character back to idle enabling the character to move again and do not want the character sliding a bit while the throw animation is still playing but moving, this was just to ensure that the animation ended smoother.
Throwing the coin was also done with raycasting, instead of press the left mouse button we set that up to be a right mouse click and a one use item, so as the code previously shows, it will stop the player to throw the coin, then will not let the player throw another coin for the rest of the level.