Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

[Solved] Playing an animation on Loop through Animator?

Discussion in 'Animation' started by Deleted User, Jun 10, 2015.

  1. Deleted User

    Deleted User

    Guest

    Animator's Play method will only play a state once. Is there a way to switch state on animator or loop a state?
     
  2. Deleted User

    Deleted User

    Guest

  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,387
    Make sure your animation clip is set to Loop. (Inspect the clip and tick Loop Time.)

    Animator.Play() switches the animator to a state. If you don't transition out of that state, it will stay in the state. If the state has an associated animation clip, it will play that clip using whatever loop mode you've set.
     
    Dominik-L and (deleted member) like this.
  4. Deleted User

    Deleted User

    Guest

    Yes, it's set to Loop Time. When I tried to use "Play" it just played it once. I'll try again just to make sure.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    11,387
    It is perhaps transitioning out of the state?
     
    eMsylf likes this.
  6. eMsylf

    eMsylf

    Joined:
    Mar 9, 2018
    Posts:
    10
    This was the case for me. It hit the requirements for a transition, and it transitioned to the next animation state.

    If the animation in the state is set to "loop," and the animation state has no transitions or the transition's parameters are not matched, the animation will loop.
     
unityunity