Why position impacts performance?

I’m having this strange issue:

I have a situation in which a set of 25 game objects has to be moved (teleported)… Game objects are disabled at first, then they are moved and enabled, one by one, each of them is disabled by the gameplay process, when all become disabled they are moved to another location and then re-enabled again. I don’t have any performance issues when this process occurs at floor level Y=0, but when Y=-2,700 the moving process takes more than 1 second, which is unacceptable. The same code is used in all cases, so the problem seems to be on the physics engine. These game objects are just static colliders that serve as floor, they don’t have rigid bodies.

This happens inside Physics.Contacts, so my guess is that you’re using continuous collision detection for these objects. When teleporting them far away from the origin, they are calculating contacts against everything on their path from point A to point B. The longer the path, the longer this process takes. Does this make sense?

Could you share the code you’re using to enable/disable/move the objects around?

1 Like

Are the objects maybe marked as static? If so, they shouldn’t be moved anymore maybe thats the reason

1 Like

Thanks… I think found the problem, I’m using a mesh collider and the number of vertices changes with distance, not 100% sure yet, but it seems the mesh rebuild process is forcing the physics engine to recalculate the whole world.

1 Like

Wow thats interesting thanks for the update