Search Unity

How AnimationStream prepare its workspace data?

Discussion in 'Animation' started by EthanCS1993, Sep 1, 2020.

  1. EthanCS1993

    EthanCS1993

    Joined:
    Apr 6, 2018
    Posts:
    4
    I implemented my own custom animation job based rigging system and animation system which both use playable graph.
    The animation graph is evaluated in Update(), and my rigging graph is evaluated in LateUpdate(). I noticed a very wired thing happened that the bone's transform value is different, retrieved by TransformStreamHandle and TransformSceneHandle. The stream handle give me bind pose transform value and scene handle give me the actual transform value processed by my animation graph. And also when i call GetInputStream(), it return me a bind pose data.
    But Unity' Timeline package works, when i am not using my animation graph, the character's pose is just be processed by AnimationTrack, and the same rigging graph can have the right animation stream data. The timeline is actually a playable graph, so i am just wondering what's the difference and how Unity prepare AnimationStream's workspace data?
    Thanks in advance:)
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi,

    The way PlayableGraphs blend together in the Animator is handled internally by an "invisible" layer mixer of sorts. As such, the Timeline Playable Graph does not read from the stream of the state machine either, but directly from default values.

    We wanted to address that in Animation Rigging and added sets of rules in the AnimationPlayableOutput to control how it's blended with other PlayableGraph

    https://docs.unity3d.com/ScriptRefe...ations.AnimationPlayableOutputExtensions.html

    Thus, setting your AnimationPlayableOutput like this
    Code (CSharp):
    1. var output = AnimationPlayableOutput.Create(graph, "MyPlayableOutput, animator);
    2. output.SetAnimationStreamSource(AnimationStreamSource.PreviousInputs);
    3. output.SetSortingOrder(1000);
    will ensure your output will read from the previous stream before evaluating. Also setting a sorting order value higher than 100 (the default) will have your graph evaluate after the state machine and timeline.

    In doing so, you'd probably want to have your graph evaluate with the animator instead of ticking it in `LateUpdate`. Otherwise, you wouldn't be able to read from the Animator stream.

    Hope this helps :)