Search Unity

Mecanim performance question

Discussion in 'Editor & General Support' started by hausmaus, Jan 23, 2013.

  1. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    We are seeing some performance degradation using Mecanim instead of legacy animation for our core bipeds. A test scene with 500 characters (972 verts, 49 bones each) implied a performance loss of approximately 40% which was of course unexpected.

    The test environment had a character model rigged as "Humaniod" with the Avatar definition automatically created from the model (as shown in the video here: http://blogs.unity3d.com/2012/06/20/more-mecanim/). For the test, we just had one state with a run animation with no blending, and no environment geometry. For a varied number of characters in the scene, Mecanim's Humanoid performance was consistently lower than the Legacy animation system, as shown below:

    (All tests run in Unity 4.0.0f7 pro on Win 7 x64)

    Count - 200 300 400 500
    Legacy FPS - 60 47 35 28
    Mecanim FPS - 45 29 21 17

    I don't think the animation system in 3.5 performed as well as the "legacy" option in 4.0 does, so there may already be some improvement over the older system. But in any case, are we missing any key steps that might improve the new animation system's performance?

    Any input would be appreciated. Thank you!
    -abm

    P.S. In terms of specific nomenclature, is "Mecanim" the new animation system in 4.0 regardless of whether you choose the Humanoid or Legacy animation type? In other words, is "Legacy" the 3.5 animation system, or legacy support within the new animation system?
     
    Last edited: Jan 23, 2013
  2. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    Hate to bump, could really use some insight on this issue however. Thanks.
     
  3. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Would love to hear something about this too. Are you using IK in mecanim? Make sure it's off.
     
  4. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Then, Mecanin performance for a massive game(RTS) is a bad choice?
     
  5. andreasng_pd

    andreasng_pd

    Joined:
    Oct 7, 2013
    Posts:
    13
    I'de like unity to comment on this as well. Mecanim for "crowds" seems like a bad idea.
     
  6. Games-Foundry

    Games-Foundry

    Joined:
    May 19, 2011
    Posts:
    632
    Same. Formal comparable performance test results would be greatly appreciated. We're considering migrating to Mecanim once 4.3 launches, but not if it means taking a performance hit. Currently running 4.2.1 legacy.
     
    Last edited: Oct 9, 2013
  7. mar10

    mar10

    Joined:
    Jan 30, 2014
    Posts:
    11
    i have a high poly 3dsMax rigged character that when used with mechanim just degraded in performance compared to custom animation, blending control done with scripts. is it because i have scripts that control the animation running along with mechanim or mechanim is just a heavyweight system.
     
  8. OllyNicholson

    OllyNicholson

    Unity Technologies

    Joined:
    Jun 17, 2011
    Posts:
    142
    Mecanim is a significant step in to the future for real-time animation systems. It provides a super powerful set of tools to help with simplifying an animation workflow that provides logic (state machine) and re-targeting of humanoid animation, amongst other features. Mecanim Humanoid animation system can be somewhat slower than legacy (no re-targeting, IK or state machine) in that they provide completely different functionality. For the addition of that functionality you will find Mecanim very optimal.

    So if you wish to compare straight up performance, you would be closer to comparing oranges with oranges (rather than lemons) if you compare Mecanim Generic (non humanoid) with Legacy where you will find things much more on a par.

    In any case here is a cool video of 2000 character on screen with Mecanim: http://www.youtube.com/watch?v=2-9S2fNdH6E&feature=youtu.be&t=1h27m55s
     
    Last edited: Feb 25, 2014
    wayneglows likes this.
  9. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    can you please post link to sample project that we can all download and see how you've done it.. thanks in advance!
     
  10. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    i did some simple testing where i put n characters just walking straight and i was able to place just over 2x the number of legacy characters vs mecanim characters...

    so if you want hundreds of bots i cant see how that would be done with mecanim and get a reasonable framerate. i mean the testing i did were extremely basic just walking no real logic beyond simple controller hardwired to loop on walk...
     
    jpthek9 likes this.
  11. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya show us the code, otherwise we have no idea what kinds of tricks you guys played to get that to work, or what limitations it has, or god knows what.
     
    jpthek9 likes this.
  12. wayneglows

    wayneglows

    Joined:
    Mar 12, 2013
    Posts:
    17
    Another bump for this code. I am running around 200 low poly characters with a looping idle animation and getting around 20 FPS in the editor and 25 on stand alone. Over 50% of the CPU is taken up by Animator.
     
  13. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Necrobump from here too, I can't possibly imagine Mecanim handling thousands of characters and I'd be very interested in knowing how to make that happen, if someone from Unity has some insight. Seems to me you're still better off using legacy animations if you have a huge amount of animated objects.
     
  14. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    did legacy still better in 5.3 ?? i'm trying to make game for android so if deference is big between legacy and humans i think i will use legacy
     
    Ali_V_Quest likes this.
  15. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    The Mecanim animator introduces some overhead, so if you don't need the blend trees and statemachines, legacy is faster. You should probably try both and profile though.
     
    xxhaissamxx likes this.
  16. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    oooooh thanks i thought i can use legacy with animator but now i understand animator system is the problem thanks a lot
     
  17. xxhaissamxx

    xxhaissamxx

    Joined:
    Jan 12, 2015
    Posts:
    134
    i just tested with one animation and looping and there is no deference
    207 legacy with animation get 12-13
    207 generic with animator get 12-15
    207 human with animator get 12-15
     
  18. John-Catan

    John-Catan

    Joined:
    Jun 12, 2014
    Posts:
    13

    hi, i'm very interested in your 2000 character on screen with Mecanim example. Could you share in detail, how this was achieved? thanks
     
    Deleted User and Ali_V_Quest like this.
  19. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    any updates on this ? (can mecanim handle 2000 characters on screen without additional optimization ?)
     
  20. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    So trying to optimize my game I just discovered this mecanim issue, unfortunately replacing humanoid to gereric rigs is out of the question at this stage, would also like to know how to put "2000 character on screen with Mecanim"...
     
  21. QGGameDesign

    QGGameDesign

    Joined:
    Aug 28, 2020
    Posts:
    8
    so, years after this was posted OllyNicholson nor anyone at unity had the respect towards the community to clarify this, to put it simple: Mecanim is a great blending tool and a piece of junk when it comes to performance and mobile. thanks for clarifying that oly...
     
    wayneglows likes this.
  22. wayneglows

    wayneglows

    Joined:
    Mar 12, 2013
    Posts:
    17
    I never got the code either and never could pull it off in 2018 or 2019. I haven't tried large scale stuff like this in a couple of years because DOTS has been a train wreck for us so we unfortunately had to move to Unreal.