Hey guys,
I imported an animation from 3dStudiosMax and whenever it is running in the scene my frames drop from 140 fps to 19-20 fps. Ive looked in the profiler and it says the Animation Mesh.BakePhysXCollisionData is the culprit taking 40 ms. Any info would be greatly appreciated.
Without seeing the animation or it’s data, it’s really hard to tell what might cause that much of a slow down.
A shot in the dark would be to check if the mesh has a mesh collider attached and going into the mesh asset and disabling generate colliders.
I am seeing the same problem. It definitely has something to do with using Mesh Colliders on the animated geometry. I guess the program must recalculating the collision mesh each frame and is being very inefficient. What is strange in my case is that the mesh itself is not changing shape, only its position and rotation are changed by the animation.
I found if I replace the Mesh Collider with a Box Collider or one of the other simple colliders, frame rate does not suffer. Unfortunately, I need to use mesh colliders in my case for accuracy.
Im thinking it has something to do with the animation scaling. It took us some time to figure out we needed to scale with the fbx importer file rather than doing it in the prefab. As soon as the animation starts running it scales up or down to whatever your import scale was set to. Maybe the colliders are still being scaled every frame? Anyway, thanks for the post. I will be definitely changing over to box colliders for now. Ill continue looking into it when i get some more time.
Sorry to bring up a dead page. I am having the same problem with animating objects with mesh colliders, as well as box colliders. It doesn’t matter if I am animating them via code or Animation Panel. The objects I am animating are platforms. They run just fine without the animation applied (70+fps), but when I apply the animation it drops to about 7fps. I need the platforms to have colliders and would like them animated, but I cant figure out a solution. I am a newbie at all of this so any help if greatly appreciated.
Here is an example of how simple the code that I am using to animate a platform.
function Update() {
transform.Rotate(0, 5, 0);
}
you know, update is called every frame. you are rotating that thing 5 degrees every frame.
Even if I rotate it 5 degrees over 10 seconds I still have the problem.
Rotating an object is trivial and won’t cause any framerate drop. “transform.Rotate(0, 5, 0)” is framerate-dependent (should be 5*Time.deltaTime), but otherwise is standard…not enough info to say what’s going wrong.
–Eric
hello, i wanted to tell you all, that in addition to colliders being able to drop the FPS of an animation, i have observed that non-uniform scaling of a gameobject that also has a collider (anisotropic scaling) can cause significant drop in FPS, with the Mesh.BakePhysXCollisionData taking a significant % of cpu. In my case, it just eats up CPU completely.
this can happen inadvertently if you do any parenting or un-parenting… because at those times scales can be automatically calculated by Unity, and sometimes, due to marginal errors, you will end up with a non-uniform scale.
one possible solution is… if you have a gameobject with scale 1,1,1 before parenting, and then you parent… you might end up with scale 1.0000001, .9999999, .99999998… you could manually set scale back to 1,1,1 This could have the side effect of slightly altering the size of the object, but hey, you just got your CPU back! 
i believe the issue is that matrices with non-uniform scale are very difficult to invert, and finding the inverse of a matrix might be a key operation in the physics calculations of the physics engine.
hello, i wanted to tell you all, that in addition to colliders being able to drop the FPS of an animation, i have observed that non-uniform scaling of a gameobject that also has a collider (anisotropic scaling) can cause significant drop in FPS, with the Mesh.BakePhysXCollisionData taking a significant % of cpu. In my case, it just eats up CPU completely.
this can happen inadvertently if you do any parenting or un-parenting… because at those times scales can be automatically calculated by Unity, and sometimes, due to marginal errors, you will end up with a non-uniform scale.
one possible solution is… if you have a gameobject with scale 1,1,1 before parenting, and then you parent… you might end up with scale 1.0000001, .9999999, .99999998… you could manually set scale back to 1,1,1 This could have the side effect of slightly altering the size of the object, but hey, you just got your CPU back! 
i believe the issue is that matrices with non-uniform scale are very difficult to invert, and finding the inverse of a matrix might be a key operation in the physics calculations of the physics engine.
Hello,
I wanted to confirm that what imnieves describes is indeed the root of my problem as well. Thank you for the information!
Essentially I have a system that builds a character. The character is created by different parts (ie, legs → torso → arms/head) that are parented together. One of the objects (the legs, at the bottom of the parenting tree) had been flipped (I scaled it by -1 in X and Z). Later on when building character at run time I was experiencing a 40 frame drop with that certain set of legs (only when the animator was turned on).
So anyway, thanks so much imnieves, you’ve saved me countless troubleshooting time (as the rig in question was the most complex one, I was going to start messing with it to see if it would work better).