Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Animation plays while button held down

Discussion in 'Animation' started by ostrich160, Dec 21, 2014.

  1. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
    This might be a fun little challenge for you guys. How would I make it so an animation plays while I have a button held down, stops when I release it, BUT resumes when I hold it down again. So lets just say its a 5 step animation, and I hold it down for 2 steps, 1 and 2. When I release it, it stops. When I hold it down again, it resumes from 3, as oppose to starting again
     
  2. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    If you are using the Animator component simply change the value of Animator.speed to 0 when the button is not pressed and 1 when it pressed.