Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Can Animation Rigging Be Used With FixedUpdate?

Discussion in 'Animation Rigging' started by Phong, Feb 2, 2021.

  1. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,093
    My Animator is configured to execute in FixedUpdate instead of Update. I am using it to pose a physics powered ragdoll. Looking through the code for RigBuilder I saw this:

    Code (CSharp):
    1.         void Update()
    2.         {
    3.             if (!graph.IsValid())
    4.                 return;
    5.  
    6.             syncSceneToStreamLayer.Update(m_RuntimeRigLayers);
    7.  
    8.             for (int i = 0, count = m_RuntimeRigLayers.Length; i < count; ++i)
    9.             {
    10.                 if (m_RuntimeRigLayers[i].IsValid() && m_RuntimeRigLayers[i].active)
    11.                     m_RuntimeRigLayers[i].Update();
    12.             }
    13.         }
    There is nothing similar for FixedUpdate. Does AnimationRigging work with FixedUpdate?
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,093
    It also looks like the RigBuilder is hardcoded to execute in gametime. I am manually stepping my Animator.

    Code (CSharp):
    1.             PlayableGraph graph = PlayableGraph.Create(graphName);
    2.             graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
    3.  

    Can the RigBuilder be configured to be stepped manually?
     
  3. Grant151

    Grant151

    Joined:
    Sep 12, 2013
    Posts:
    65
  4. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,093
    I am coming to the conclusion that it is not possible to step the RigBuilder manually. Hopefully somebody will contractict me. I haven't seen the source code for Playables that Animation Rigging is based on, but it looks like it is a DOTs/ECS system. I believe the "System" is hard-wired in Unity to run when the Animator runs (either in between Update and LateUpdate, or after FixedUpdate). There is no way to hook into this system and stepping the Animator manually (by disabling and calling animator.Update) doesn't trigger the PlayableGraph.Evaluate.

    I have run into the issue that the playables code executes off the main thread so it is not possible to query legacy unity objects like Transforms, PhysX RigidBodies etc.. from inside the RigConstrinats code.

    For these reasons I have started implementing a clone of AnimationRigging that runs on the Main Thread.
     
    Celezt likes this.