Search Unity

connect Timeline AnimationPlayable output to an AnimationScriptPlayable

Discussion in 'Timeline' started by ahmidou_mpc, Sep 18, 2019.

  1. ahmidou_mpc

    ahmidou_mpc

    Joined:
    Aug 13, 2019
    Posts:
    9
    Hi, I would like to have the animation generated by Timeline to drive an AnimationScriptPlayable, is it possible?
    AnimationScriptPlayable.AddInput(...) is taking an AnimationClipPlayable that should be created from an AnimationClip, but I was wondering if I could get one directly from Timeline?

    Thanks.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, it's a bit complicated, and depends how you'd like to use it. If you want the animation script playable to be run as part of the timeline, you can create your own AnimationTrack and Clips which generate exactly the playable graph you need. The drawback is several of the root motion options of the regular timeline track would not be available.

    Or, if you want the output of the timeline animation track to feed into a custom animation script playable, you could add it into the playableGraph generated by timeline, after the graph is created (playableDirector.RebuildGraph() will built the playable graph, and playableDirector.playableGraph is the resulting graph). This is possible, but can be tricky to get right, since you need to update both the correct branch of the graph, and the corresponding PlayableOutput.
     
  3. ahmidou_mpc

    ahmidou_mpc

    Joined:
    Aug 13, 2019
    Posts:
    9
    Thanks for your reply, I managed to get something working with
    Code (CSharp):
    1. AnimationPlayableOutput.SetAnimationStreamSource(AnimationStreamsource.PreviousInput)
    in the same graph.
     
    seant_unity likes this.