Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Animator.ProcessRootMotion even when not using root motion.

Discussion in 'Animation' started by GloriaVictis, Aug 16, 2019.

  1. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    Hello,

    We are using 2017.4.LTS version of Unity, our characters use Generic animator type and no root motion at all, the bool is set as false. Still tho, the profiler shows Animator.ProcessRootMotion with around 0.1ms per animator update - which, as many times we have 50+ character on screen significantly affect our FPS.

    Is it normal behaviour or we could evade it anyhow?
     
  2. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    Bump, can anyone confirm this is normal behaviour or how to evade that?
     
  3. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
  4. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    yes this is expected, in 2018 this profiler tag has been renamed to Animators.ProcessGraphJob.

    Animator.ProcessRootMotion was a bad name for this step.

    this step is mandatory as it does evaluate the whole animation graph
     
  5. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    Okay, thank you
     
  6. TP-Fab

    TP-Fab

    Joined:
    Jul 10, 2019
    Posts:
    16
    Hi, resurrecting this thread as in 2020.3 I can still observe AnimationScriptPlayable.ProcessRootMotion in the profiler (despite ApplyRootMotion disabled), directly under Animator.ProcessGraph (itself included in Animators.ProcessGraphJob) . What's going on with this?
     
    floky likes this.
  7. Kleptine

    Kleptine

    Joined:
    Dec 23, 2013
    Posts:
    186
    Unity still runs the ProcessRootMotion function of IAnimationJobs, even if there is nothing to be done. None of the Animation Jobs in the AnimationRigging package actually use RootMotion, but Unity still schedules jobs for them!

    This means that if you have a lot of very lightweight rigs / AnimationScriptPlayables, Unity spends half of the animation time scheduling jobs that literally do nothing.

    :(

    See here, where it schedules the ProcessRootMotion jobs for MultiParentConstraintJob:
    upload_2022-5-4_22-14-49.png

    ... for which the definition is empty:

    Code (CSharp):
    1. /// <summary>
    2.         /// Defines what to do when processing the root motion.
    3.         /// </summary>
    4.         /// <param name="stream">The animation stream to work on.</param>
    5.         public void ProcessRootMotion(AnimationStream stream) { }
    6.  
     

    Attached Files:

  8. Kleptine

    Kleptine

    Joined:
    Dec 23, 2013
    Posts:
    186
    @Mecanim-Dev Is there any way to force these root motion jobs to be skipped? This is happening even with Animator.applyRootMotion set to false. Unity 2020.3.17f1
     
  9. Kleptine

    Kleptine

    Joined:
    Dec 23, 2013
    Posts:
    186
    You can see here how it's spending half of the animation time, just on running these empty jobs:

    upload_2022-5-4_22-18-7.png
     
    GloriaVictis likes this.
  10. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    227
    Why not test this with 2021.3 LTS or even 2022?
     
  11. Kleptine

    Kleptine

    Joined:
    Dec 23, 2013
    Posts:
    186
    Just not worth the time, unless it seems like something that would be fixed. This seems like an intentional architecture decision, not a bug. Plus, we're stuck on 2020.3 for the time being.

    We solved this by writing our own animation logic in a custom job, and skipping the Animation Rigging package entirely. That made it 10-20x faster, haha.
     
  12. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133

    Sounds awesome! Even though of sharing the solution via asset store for example?
     
  13. Kleptine

    Kleptine

    Joined:
    Dec 23, 2013
    Posts:
    186
    GloriaVictis likes this.
unityunity