Physics.simulate taking a long time with an object

Hi I’ve run into a confusing problem.

Just set up a new model in my game and for some unknown reason they make the physics system has takes forever to process (200ish ms according to the profiler) when the new object is present.

The reason its confusing is that for the purpose of physics the object is only a rigid body and a mesh collider.

Through experimenting I found that neither of these were the problem, the problem is in fact an array of objects that are a child of the main object which are just mesh renderers [~200 gameObjects rendering only 1 of 4 different meshes so lots of batching] and some custom scripts. All of this should have nothing to do with the physics simulation since they don’t have any colliders.

I’m completely lost on why this is happening so any help would be appreciated.

Then your script which contains a list of AIStatsList will allow full editing, or is that not the case?

1 Answer

1

I’ve noticed slowdowns before when moving objects with lots of children, although 200 ms is rather surprising. Make absolutely sure there aren’t any colliders (even trigger colliders) or rigid bodies in the children, and that none of them (or the object itself) are marked as static.

The other thing you should definitely do is combine the meshes into one. Unity isn’t great at large transformation hierarchies, particularly ones that get moved around.

Also, how many triangles are there in your mesh collider?

Checked everything definitely none. Just ran a little test and it seams the cause is the mesh renderers as when I run a "turn all mesh renders off" script the lag disappears

You know, I wonder if some sort of interaction between the dynamic batching system and the mesh collider is happening. Does the problem occur when you've got a different sort of collider attached instead?

Nope just tried, disabling the mesh collider, removing the mesh collider and replacing it with a cube collider and all result in the same 200ms per frame lag