I
I
Ilya Chirkov2014-08-23 18:45:00
Unity
Ilya Chirkov, 2014-08-23 18:45:00

How to change the playback speed of a 2D animation through code?

With animation["animation"].speed, nothing happens and the console says that the GO to which this script is attached does not have any animation, although it is animated (through the same script) and everything works fine.
So how can I change the playback speed of a Clip through code?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Chirkov, 2014-08-25
@fenicsis

In general, the solution is:

Animator animator;
animator = GetComponent<Animator>();
animator.speed = 1F;

True, it changes the speed of all animations, but if I change the speed along with the animation change, then I get exactly what I need.

I
Ivan Khlopianik, 2014-08-25
@ping_rulezzz

Could you schematically describe your GO; where exactly is the script attached; a piece of code where you change the speed and completely error.
PS: animation["animation"].speed should work, the problem, apparently, is in some trifle

E
EndUser, 2014-08-24
@EndUser

If you allow globally, then Time.timeScale = 0.1f;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question