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.