prime31 / Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
MIT License
1.76k stars 355 forks source link

Collider no longer registers with physics system when disabled #739

Closed thatpixelguy closed 1 year ago

thatpixelguy commented 1 year ago

There are a couple of situations where a Collider will register itself with the physics system when it's disabled. This can cause phantom collisions, which has resulted in the acceleration of a certain programmer's descent into madness.

Example 1:

var collider = entity.AddComponent(new Collider());
collider.Enabled = false;
// later, once entity.Update() is called, the collider will be added to the entity's component list
// and RegisterColliderWithPhysicsSystem() is called, ignoring collider.Enabled

Example 2:

collider.Enabled = false;

// SetLocalOffset ignores collider.Enabled and re-registers it with the physics system.
collider.SetLocalOffset(Vector2.Zero);