make sure body exist in world & collision detection :(

Aug 5, 2011 at 2:34 AM

Hi all

I was wondering if there is a function that is fast to make sure that the body I have is exist in the world

instead of using foreach body in world.BodyList and if statement ...... any faster method

 

and I am lost with collision detection !!! the documentation is good but I didn't understand any of collision detection section :(

when two bodies are collides how to handle ..... in The FarSeer XNA samples there is no implementation for collision .

please I want a simple sample for collision when two bodies collides they will be deleted ,

and one last thing . like the car when it move on a flat line the wheel will keep moving for unlimited rounds .... there is no loss force in it !! why !!

thanks all

I really appreciate all the help

Aug 5, 2011 at 12:25 PM

"I was wondering if there is a function that is fast to make sure that the body I have is exist in the world instead of using foreach body in world.BodyList and if statement ...... any faster method"

 I don't think there is, but you could always use the 'user data' to point to the world it is in.

"when two bodies are collides how to handle"

You can register for collision events on the body:

this._Body.OnCollision += HandleCollision;
this._Body.OnSeparation += HandleSeparation;


private void HandleSeparation( Fixture fixtureA, Fixture fixtureB )
{
    // ...
}

private bool HandleCollision( Fixture fixtureA, Fixture fixtureB, Contact contact )
{
    // return 'false' to ignore this collision; otherwise, 'true'...
    //
    return true;
}

The two fixtures contain the body, and your userdata could contain the world the bodies are in.

"like the car when it move on a flat line the wheel will keep moving for unlimited rounds .... there is no loss force in it !! why !!"

Because you are not simulating air resistance, or other force conversion affects.

Try adding AngularDamping and LinearDamping to the body:

this._Body.AngularDamping = 0.2f;
this._Body.LinearDamping = 0.2f;

I hope this helps!

Aug 5, 2011 at 12:47 PM

thanks very much !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

that helps

thanks again !!!!