Currently I have 102 “agents” (units) in my game. With animations turned off, and all of them on-screen at the same time, I am getting 145 frames per second (according to my stats window, and I don’t have Unity Pro, so no profiler).
So here is what I get with animations turned off:
102 Visible skinned meshes
0 animations
145 fps
Main thread: 6.5 ms
Renderer: 6.8 ms
Now here are some of my stats with animations turned ON:
102 Visible skinned meshes
102 animations
52 fps
Main thread: 19.0 ms
Renderer: 8.1 ms
Explanations and Questions:
As you can see, when animations are turned off I get 145 fps. With them turned on, I get 52 fps. That’s a difference of 93 fps! Now, I am relatively new to game programming, so I’m definitely not ruling out that it could be the way I’m scripting animations is incorrect. But is this to be expected? Should 102 animations eat up 93 fps? Is this kind of normal for your average game.
For some quick background information. I have simple capsule colliders on all of my objects, but I’m not sure if that would affect anything? I am using animation.Play and animation.Crossfade via scripting, and they are placed in the Update() function itself. This is the way the Animations reference in Unity had it, so that’s what I did. Other questions pop into my mind as well, such as is it the game engine (i.e. Unity itself and the way it handles animatons)? Are the animations themselves too complex, or too long?
I read somewhere else that mentioned sometimes colliders have to be re-built on every frame if they are set a certain way, but I’m not sure if that would apply in my case or not, as I am only using simple colliders?
All in all, is there something I could be missing, or some setting or lines of code I’m missing that would make animations take up that many frames per second? Thanks for any suggestions or help.