- Home /
Stop animation at the current frame
The character currently has two states, walking and idle. idle state is just a single sprite. walking animation has 4 sprites/frames. Currently I'm using this kind of code to play the animation
if(Input.GetKey(KeyCode.A) anim.SetBool("isWalking",true);
else //any other key or no key
{
anim.SetBool("isWalking",false);
}
When A key is released, the animation stops but only after playing the entire 4 frames. So it looks really odd since the walking animation stops after ~0.5 seconds after playing entirely. I want it to stop at whatever frame is being played when the key is released and immediately return to the idle state.
Answer by shay4545 · Aug 02, 2015 at 03:48 PM
Go into the animator window and select the transition from walking to idle state. Then uncheck "Has exit time." This will allow the transition to occur right when the condition for the transition is met, and not after the animation completes.
Your answer
Follow this Question
Related Questions
How to stop sprite animation on single frame? 0 Answers
Mecanim How get the last frame the animation? 0 Answers
Mecanim: Stop/Hold Animation at the end 3 Answers
Mecanim MatchTarget & Generic Rig 1 Answer
AddMixingTransform with Mecanim 1 Answer