Search Unity

Animation Update Loop

Discussion in 'Animation' started by Mecanim-Dev, Apr 10, 2018.

Thread Status:
Not open for further replies.
  1. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi guys,

    while we are updating the documentation, I thought it could be nice if you could have an early access to what the animation update loop look like. Squared box are not actual callback but processing done by the animation system

    internalAnimationUpdate.png
     
  2. gambitslacklines

    gambitslacklines

    Joined:
    Feb 23, 2015
    Posts:
    14
    I had just posted a question about "RootRotation".

    Will there be any option to use RootRotation for the X and Z axis? Right now it just works for the Y Axis.

    This works fine for normal Walk-Movement, but not if you want to have a character controller which follows things like Motion-Capture animations that involve Flips on the X and Z Axis.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Nice!

    Where does a PlayableGraph fit into this? We're playing animations through doing this:

    Code (csharp):
    1. graph = PlayableGraph.Create();
    2. AnimationPlayableOutput animOutput = AnimationPlayableOutput.Create(graph, $"{name}_animation_player", OutputAnimator);
    3.  
    4. PutStuffInGraph(graph);
    5.  
    6. graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
    7. graph.Play();
    Does everything that has to do with evaluating the graph happen in ProcessAnimation?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi baste,

    no, the graph evaluation is splitted into a few stages

    there is the PrepareFrame stage which set the weight on each playable, this happen right after the statemachine evaluation
    then you have the ProcessRootMotion and then ProcessAnimation.

    Remember you can inject a AnimatorControllerPlayable into a graph so we must have the same evaluation pipeline for controller and graph to get the same behaviour.
     
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    That makes sense. Could you perhaps add PrepareFrame to the chart, for clarity?

    It'd also be nice if there was a single page in the documentation that outlined exactly what happened for each of the stages in the loop. Everything is processing animation, so the label "ProcessAnimation" doesn't really say much on it's own.

    Also, when you're saying "PrepareFrame stage which set the weight on each playable", I'm a bit unclear on what you mean. I set the weight for Playables in Update. Does PrepareFrame set the weight for playables in AnimatorControllers, or does it do post-processing of weights set elsewhere (ie. transfering to internal format, normalizing)?
     
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    yeah sure, it should go between OnStatemachineEnter/Exit and ProcessRootMotion

    yes exactly, depending on the result of the statemachine, the prepare frame stage does read this result and setup all the weight on the playable in the controller.

    In your case it fine to set the weight from a monobehaviour
     
  7. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,537
    Nice, much needed update thanks for posting!
     
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Thanks, but I meant to the chart graphic in the documentation.

    That being said, doesn't seem like the chart you posted in the first post has gotten posted to the manual. Still not ready?
     
  9. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    it still been processed by the doc team, there were pretty busy rewriting part of the manual so they didn't have time to fix this, hence why I did put it on the forum meanwhile.
     
    twobob likes this.
  10. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    @Mecanim-Dev I noticed that the diagram in the documentation has been updated (so this thread should probably not be stickied any more), but it doesn't mention anything about multithreading except for stuff about StateMachineBehaviours.

    Specifically, I'm trying to find out what parts of a Playable Graph are multithreaded but there doesn't seem to be any documentation covering the topic:
    • Presumably, having Animation Job A connected to Job B means they need to run one after the other, but if both are instead connected to some other playable then they could be run at the same time. Is that correct?
    • Are any of the other playable types multithreaded?
    • Can playable outputs be mulththreaded?
    • Can separate graphs be multithreaded?
     
  11. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    LudiKha likes this.
Thread Status:
Not open for further replies.