Let’s implement the animations, but first I have to implement a model for our player, we can not continue with the capsule that currently acts as a placeholder.
The time has come to animate it, luckily our package gives us not only the model but also a couple of animations to use. Mainly we will use two animations its “Idle” which will be active when it is really still, and the walking one when we move between two points.
Select the 3d model and add the Animator component. We will be asked for a “Controller”. Then in our animations folder let’s create one for our character.
Double-clicking on it will open the animator tab.
We drag the animations we want to use into this tab in our case Idle and Walk.
The idle animation will be linked directly to the entry block, instead of for the Walk animation, we need to build a transaction between the two animations.
To do this, right-click on the mouse and choose to Create a Transition and link to the next block. You have to do the same thing in reverse between Walk and Idle to return to the starting state.
Once we have inserted the two transitions we must define how the transaction between the two states takes place. To do this in the animation tab click on Parameters and create a bool variable, in this case, the bool is perfect because we have only two states.
Finally, we pass to the code, we have to modify the parameter just created when the movement takes place and reset it to the initial value when the distance between the player and the destination is less than 1.