Sunday, August 7, 2016

unity - Changing animation speed at runtime


Is there a way in Unity to change the animation speed of an animation managed by an animator controller (Mecanim)?


I'd like to do that at runtime so that I can speedup and slow down an animation based on conditions in code.



Answer



You can change the Speed of the Animator itself, which may be adequate for what you are trying to do:


http://docs.unity3d.com/ScriptReference/Animator-speed.html


However, if you need to adjust each animation individually, you will need to use the AnimationState object instead.


http://docs.unity3d.com/ScriptReference/AnimationState-speed.html


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...