Search Unity

Multiple PlayableClips playing through the same Animator

Discussion in 'Animation' started by mhofer, Oct 10, 2017.

  1. mhofer

    mhofer

    Joined:
    Aug 30, 2017
    Posts:
    18
    I have a script that lets me play an AnimationClip on a certain Animator (using the Playables API)

    BUT if I play one clip on the Animator, then have another script play an animation through the same Animator and then go back to the first script and try to play that animation again it doesn't work. Is there a way to "reset" the Animator so the first one can play again?
     
  2. TantzyGames

    TantzyGames

    Joined:
    Jul 27, 2016
    Posts:
    51
    If the clip is not set to looping then you'll need to set it to the beginning for it to play again: playable.SetTime(0);
     
  3. mhofer

    mhofer

    Joined:
    Aug 30, 2017
    Posts:
    18
    After some more experimentation, this works the best:
    Code (CSharp):
    1. m_PlayableGraph.Stop();
    2. m_PlayableOutput.SetSourcePlayable(m_PlayableClip);
    3. m_PlayableClip.SetTime(0d);
    4. m_PlayableGraph.Play();
    But it still stops whatever was playing through that animator, so I guess there's no real way around using a Mixer.
     
  4. TantzyGames

    TantzyGames

    Joined:
    Jul 27, 2016
    Posts:
    51
    Yes, doing that replaces the previous clip so it will stop. If you want to blend from one clip to another you need a mixer.

    In your example do you need to stop and play the graph, or is it enough just to change the clip?