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

How can I get the value of Body.IsSensor?

Topics: User Forum
Jan 2, 2014 at 7:33 PM
I want to get the value of Body1.IsSensor and then assign the value to Body2.IsSensor. How can I do that?
I tried it like that but it's not working.
Ball2.IsSensor = Ball1.IsSensor;
The property or indexer 'FarseerPhysics.Dynamics.Body.IsSensor' cannot be used in this context because it lacks the get accessor

What is wrong? What should I change?
Jan 3, 2014 at 5:27 PM
Set the IsSensor property on the Fixture(s) rather than the body
Jan 3, 2014 at 5:29 PM
How can I do that?
I always did it like that: Body.IsSensor = true/false;
Jan 4, 2014 at 11:21 AM
Edited Jan 4, 2014 at 11:22 AM
To do it manually you could do this:

body.FixtureList[0].IsSensor = value;

or to set them all:

for (int i = 0; i < body.FixtureList.Count; i++)
body.FixtureList[i].IsSensor = value;

And if you don't mind setting all fixtures on the body sensor data at the same time you could use the above code in a setter for the IsSensor property in Body.cs so you could use body.IsSensor = value.
Marked as answer by Wizard999 on 1/4/2014 at 11:14 AM
Jan 4, 2014 at 7:14 PM
Thanx. It works.