This project has moved and is read-only. For the latest updates, please go here.

Turn off collision

Feb 18, 2011 at 11:47 PM

I'm not sure if you can do this. But can you turn off collision unless the object is a certain distance away from another object?

So nothing collides outside of a radius from a player object.

Will this optimize the PhysicsEngine more or will it actually slow it down?

Feb 19, 2011 at 2:00 AM

The engine does this already. It is called a broad phase and uses a highly optimized tree based algorithm to determine if fixtures can collide or not. When fixtures come close to each other, we check if they touch each other.

Feb 19, 2011 at 4:13 AM

but is it possible to turn off all checks when its off screen for gameplay reasons?

Feb 19, 2011 at 9:39 PM

Yes, indeed it is.

If you create an AABB that is the same size as the screen, then you can iterate all the fixtures that are outside the AABB and disable them (body.Enabled = false). That would take them out of the physics simulation until you re-enable them.

Feb 23, 2011 at 7:50 PM

Sorry, but wouldn't that disable movement?

Feb 24, 2011 at 9:16 AM

In this case you would want to use collision categories. Just set your fixture CollisionFilter's CollisionCategory and CollidesWith to Category.None