Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Animation Update Loop

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

  1. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,623
    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:
    3,519
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,623
    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:
    3,519
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,623
    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:
    6,210
    Nice, much needed update thanks for posting!
     
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    3,519
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,623
    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.