How to change IsSensor property programmatically?

Feb 13, 2011 at 1:21 AM
Edited Feb 13, 2011 at 1:21 AM

Hi, I have some behaviors (like PhysicsObjectBehaviors and a PhysicsControllerBehavior for LayoutRoot) attacthed to various object on the page. It works great, but I decided I want to turn something into a sensor when a collision is detected. I have tried code similar to what you had on the front page like


physicsController.PhysicsObjects["ball"].GeometryObject.IsSensor = true;

and GeometryObject isn't even recognized and gives me a 'PhysicsSprite does not contain a definition for GeometryObject...' at compile. I don't know why this is happening, or how else to reach the IsSensor property.

John Simmons
Feb 13, 2011 at 4:46 PM

Some properties like IsSensor are at the Fixture Level, so it would be something like: 


          foreach (Fixture f in sprite.BodyObject.FixtureList)


                f.IsSensor = false;



Feb 13, 2011 at 8:44 PM

Thanks, I'll try that. Thanks for the quick response.