public void SetSensor(bool sensor) { if (IsSensor == sensor) { return; } IsSensor = sensor; if (Body == null) { return; } // Flag associated contacts for filtering. ContactEdge edge = Body.GetContactList(); while (edge != null) { Contact contact = edge.Contact; Fixture fixtureA = contact.GetFixtureA(); Fixture fixtureB = contact.GetFixtureB(); if (fixtureA == this || fixtureB == this) { contact.SetAsSensor(IsSensor); } } }