Hi! I’ve spent some time creating cool mecanim controllers for my enemies. But after I’ve added 25 enemies on screen, with all the optimizations (no unnecessary bones like hands, GPU skinning, object optimization on) I realized that it uses 6ms. That is just way too much.
I did try everything I could, making lowest settings possible, still, inside profile, that sendTransfromChanges step takes all the cpu power, and it seems like bottleneck.
My ideas was to use update it not every frame. Like, there is option “Animation Update Mode - Physics” which updates animation along with the physics. This create good FPS/bad fps spikes. What I would like to, is to update animation in-between physics updates, when CPU has free power. But I do not see any options to update mecanim manually, when I want it to.
My other idea was to cache animation transforms, to utilize free memory I have instead of CPU, there are some functions like “RecordPlayback”, but seems they are for something else. When I’m testing with setting “StartPlayback”, or setting animation speed to 0, I still get those 6ms of cpu usage.
Though this is odd, when speed is 0, or “StartPlayback” is on, ideally animation should not be process, but inside profiler, that sendTransfromChanges step is still being executed.
Can anything be done here, or all I can do is reduce enemy count/reduce their bone amount considerably?
Yeah I believe when I asked about this, the author of mechanim said something like he’d make a best practises blogpost at some point, perhaps he just needs a reminder and some spare time?
I see, so this question was asked before. I think it needs to be in documentation somewhere. From the early mecanim promotion demos, I’ve got impression that it can handle 100s of models, and so I ended up in this trap. Though it is my fault too. Prototype and perfromance check, always prototype and performance check…
I believe that’s if they’re using the same frame or something (haven’t looked terribly deeply into it). In any case, mecanim is always slightly slower than legacy. You want mecanim because of the power it gives you, and it’s not a small amount of power, it’s pretty amazing what can be done. Are you using generic or humanoid rig? generic might be a little quicker.
I believe that’s if they’re using the same frame or something
I’ve seen this mentioned before too.
Yes, I do agree that mecanim is great system, I just did not expect animations to eat so much CPU power in general. I’m using Humanoid animation mode.
Seems like nothing can be done at this point, so I’ll try optimizing game elsewhere.
If you’re feeding variables to mecanim, this can be slow if it’s by string. Use the helper functions to get an integer id and pass those instead. Of course you’ll want to reduce the bone affect limit by lod, so far off ones have 1 bone affecting verts, while closer up it’s 2. I wouldn’t go over 2, and 2 is more than enough for all but the most demanding types ie muscle deformation would benefit from 4.