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.
  2. Dismiss Notice

My animation resets after it's done.

Discussion in 'Animation' started by The-Game-Master, Dec 4, 2014.

  1. The-Game-Master

    The-Game-Master

    Joined:
    Aug 6, 2014
    Posts:
    54
    I have an animation that aims down the sights for me. When I hold the right click (it's controlled by the animator class in a script), it goes back to the reset position and plays again and again and again. So you see him move the gun to his eyes, and hold it for a second, and the gun resets and you see the guy moving the gun to his eyes, and holding it for a second, and so on. I have it set up to not do that by using parameters, and I've done it before, but it just keeps looping. How do I get it to stay aiming down the sights?
     
  2. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    What about you make two states:
    one for idle, one for aiming, and let the mecanim to do the blending for you.
     
  3. The-Game-Master

    The-Game-Master

    Joined:
    Aug 6, 2014
    Posts:
    54
    So how would I go about doing that? I only know how to use the default state, and would all of the variables be the
    Same? Thanks!
     
  4. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    1. make one loop animation of "idle" and one loop animation of "aiming",
    2. put both into animator, set "idle" as default state,
    3. add a bool parameter named as "isAiming" in Animator, when true, transition from "idle" to "aiming", when false, transit back,
    4. try to set a reasonable blending time;

    If you need to move your character around during aiming, you might need to add a separate layer for upper torso.
     
    theANMATOR2b likes this.
  5. The-Game-Master

    The-Game-Master

    Joined:
    Aug 6, 2014
    Posts:
    54
    Awesome, thanks!