PlayableGraph: Play simple animation clip, how to find out if its done playing

Hi,

I am using playable graph api to play a simple animation clip. How to find out if animation clip is done playing? It is not PlayableGraph.IsPlaying() or PlayableGraph.IsDone(). I can get to the AnimationClip through PlayableOutput and AnimationClipPlayable, but AnimationClip itself doesnt seem to have anything indicating if its playing or not.

I am using this example from unity manual:

using UnityEngine;

using UnityEngine.Playables;

using UnityEngine.Animations;

[RequireComponent(typeof(Animator))]

public class PlayAnimationUtilitiesSample : MonoBehaviour

{

    public AnimationClip clip;

    PlayableGraph playableGraph;

    void Start()

    {

        AnimationPlayableUtilities.PlayClip(GetComponent<Animator>(), clip, out playableGraph);

    }

    void OnDisable()

    {

        // Destroys all Playables and Outputs created by the graph.

        playableGraph.Destroy();

    }

}

PlayClip returns an AnimationClipPlayable and you can then use GetTime on it and compare that to the length of the clip.

You might also be interested in Animancer (link in my signature) which is built using Playables and would save you a lot of trouble trying to make sense of their API. In particular, it has several easy ways of waiting for animations to finish.

2 Likes

That worked! Thanks very much, Ill be sure to check it out.