S
S
Segan4542017-09-10 19:24:12
C++ / C#
Segan454, 2017-09-10 19:24:12

How to interrupt animation playback in Unity?

There is a 2D character with sprite animation. When you press the key, the character moves, so the animation is played, but when the key is released, the animation does not stop until it is played to the end. GetComponent().enabled = false and GetComponent().speed = 0, as I understand it, stop the animation on the current frame, but you need to stop it and return to the initial frame. Anyone can help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pparma, 2017-09-10
@Segan454

Make it in the state animator. For example Idle and Move.
Add parameters to the animator and set these parameters to transition between states.
Change parameters from the script.
https://unity3d.com/en/learn/tutorials/topics/anim...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question