A couple of seconds into the gameplay on my Android device, I see huge performance spikes caused by "Mesh.Bake Scaled Mesh PhysX CollisionData"

In my game, a whole level is a parent object containing multiple ridigbodies with mesh colliders. Every FixedUpdate(), my parent object rotates around the player.

Rotating the world causes mesh scaling. Here is the code that handles world rotation.

 private void Update()

        Vector3 currentInput = input.GetDirection();

        worldParent.rotation = initialRotation;

        worldParent.position = transform.position;
        world.parent = worldParent;

        worldParent.Rotate(Vector3.right, currentInput.x * 50f);
        worldParent.Rotate(Vector3.forward, currentInput.z * 50f);

How can I get rid of mesh scaling ? Mesh.Bake physx seems to take effect after some time, is it possible to disable this function ?

The profiler looks like this:


Bottom-left panel shows data before spikes, the right after


2 Answers 2


When initializing the physics components for an actor within the world, PhysX needs to know about the collision geometry. PhysX either generates this geometry at run time, or loads it from a precooked cache. This link has a more detailed description of this. If unity supports pre-cooking your collision geometry, then this would eliminate the spikes caused by this.


Also, using primitive collision geometry wont require complex hull generation that is required for complex triangle mesh collision. On top of that, primitive collision checks are usually much faster for primitives such as spheres, capsules, AABB's, and OBB's

  • \$\begingroup\$ In my current example i have two colliders which have about 60 tris each, does it count as being complex ? If I used primitive collider, would I get rid of physx baking ? \$\endgroup\$ Mar 21, 2014 at 20:38
  • \$\begingroup\$ Complex geometry is essentially anything other than a bounding box, a sphere, or a capsule. Yes, using primitives would eliminate the need for baking out geometry data, as primitive shapes are represented by only a few numbers, rather than large data sets. \$\endgroup\$
    – Evan
    Mar 21, 2014 at 20:40
  • \$\begingroup\$ My game works great before the baking takes place, seems to me like the simples way would be just to disable it. \$\endgroup\$ Mar 21, 2014 at 20:43
  • \$\begingroup\$ The reason that event happens is because your game is telling PhysX it wants to use a triangle mesh or convex hull as collision geometry for certain actors. Turning that off will mean not having collision for those actors. Alternatively, you could instead use primitive geometry, or pre-cook/bake the collision geometry. \$\endgroup\$
    – Evan
    Mar 21, 2014 at 20:45
  • \$\begingroup\$ It looks that collisions work for 5 seconds without physx baking taking place. It just seems like a useless thing to me. \$\endgroup\$ Mar 21, 2014 at 20:55

(a) How big are your meshes? (b) Are they non-convex manifolds?

...These factors may lead to a high cost in pre-processing. Most games don't need to use their actual meshes for collision (or if they do, their meshes have been designed with the above factors in mind).

Suggest just using a capsule, box or sphere collider -- or collections of these (say, for different limbs). It will save you a lot of time and you'll hardly notice the difference.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .