Sensor problem

Oct 1, 2008 at 6:06 PM
I guess this thread is mainly directed at genbox.

I have created a figure composed of a few bodies connected with joints. If enough force has collided with one of the figure's bodies,
the joint attaching the body to the figure's main body gets disposed of, thereby freeing the appendage.
How I simulated this conditional force system is simply testing for a certain amount of seperation between the body's geom and incoming geom
in the geom's collision event handler function.

The problem (if you've read this far =P) is that sensors fire that seperation and therefore completely dislocates the figure's parts if the figure
touches the sensor. Well crap.

Funny enough, when I set .Enabled to false for the sensor's body the sensor still works, but only like half the time, and it doesn't kill the figure.
So I suppose that's a clue.

Any ideas on what I can do to make this work?
Coordinator
Oct 1, 2008 at 6:23 PM
"I have created a figure composed of a few bodies connected with joints. If enough force has collided with one of the figure's bodies,
the joint attaching the body to the figure's main body gets disposed of, thereby freeing the appendage."

Farseer already does this by using JointError and BreakPoint properties on joints?

"The problem is that sensors fire that seperation and therefore completely dislocates the figure's parts if the figure
touches the sensor."

So what you are saying is that when a geom touches the sensor, your implementation inside the Collide event's methods destroys the bodies joined by joints?

I'm not sure if this is what you are looking for, but you could check if the geom that collided was the sensor geom, and then don't dispose the joints.

"Funny enough, when I set .Enabled to false for the sensor's body the sensor still works, but only like half the time, and it doesn't kill the figure."

If I remember correctly, geoms should not be checked for collisions their body is disabled. Do you have any code I can look at?
Oct 1, 2008 at 8:43 PM
Edited Oct 1, 2008 at 8:48 PM

@genbox
I was afraid you were going to say that.
Since there are so many possible sensors, I've got to create a list of them to pass in the class or something.
I was hoping there'd be an easier way of creating the sensors to somehow prevent the problem.

The code is fairly confusing, so I apologize ahead of time.
This is where I make a "block" into a sensor.

 

private

 

void disableBlock()
{

 

 

//temp variables so that the block can stay in its position after the physics reset 

 

float lastRotation = blockBody.Rotation;

 

Vector2 lastPosition = blockBody.Position;

 

blockBody.ResetDynamics(); 

//reset physics to keep the block from using an old force 

 

 

 

blockBody.Rotation = lastRotation;

 

blockBody.Position = lastPosition;

 

blockBody.Enabled =

false;

 

knob.getKnobBody().Enabled =

false; //an attachment to the block there 

 

blockGeom.CollisionResponseEnabled =

false

 

blockBody.IsStatic =

true;

 

}


And this is where I test to see if it collided with anything on stage.

 

if (ps.ArbiterList.Count == 0)  
 
return isClear;
else 
 
foreach (Arbiter arbiter in ps.ArbiterList)
  {
    Console.WriteLine("Testing" + 9); 
    
if (arbiter.GeomA == inputBlock.getBlockGeom() || arbiter.GeomB == inputBlock.getBlockGeom()) 
   {
        
Console.WriteLine("Why not?"); 
        play(); //play animation
        isClear =
false;
    }

}