Animation speed needs to sync with the player movement to make it look natural. In this post, we will see how to decrease or increase the animation speed to match the player movement. If you have sounds for animation then check out our other post on how to sync audio with animation.
Using a fixed number
If your animation is set for something that has a fixed speed then you can change the animation speed once and it will remain synced.
Open your Animation controller in the Animator window. You can access the animator window from Window>Animation>Animator.
Select the animation you want to slow down or speed up.
Go to the Inspector window.
You will find a parameter named speed.
Enter value less than 1 to slow down animation and value greater than 1 to speed up.
Setting a variable speed to animation
If you have a character with variable speed then the animation speed needs to change based on the character’s moving speed.
You need to add a float variable to your animator for this purpose.
Now select the animation which you want to have variable speed. Go to the Inspector.
Remember, you need to have the speed value set to a number greater than zero.
Check the parameter box near multiplier and select the float variable you just created.
Now your animation speed will change with the float variable.
To set the float variable use the code below
Now you should be able to set the animation speed based on your requirement. If you have any other questions, feel free to leave it in the comment box below.