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()
{
input.update();
Vector3 currentInput = input.GetDirection();
worldParent.rotation = initialRotation;
worldParent.DetachChildren();
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