Collision and safty remove?

Sep 19, 2009 at 6:45 PM

Hi,

i have a Spaceship and shoots. If shoot collision dedectet with something, i will delete the shoot. Deltete works, but after that i become a KeyNotForund Exeption in DistanceGrid on Line "DistanceGridData geomBGridData = _distanceGrids[geomB.id];".

Here is my Code:

private bool OnCollision(Geom geom1, Geom geom2, ContactList contactList)
{
    physicsSimulator.GeomList.Remove(s);  // s = ShootGeom.
    physicsSimulator.BodyList.Remove(shootBody);

    s.OnCollision -= OnCollision;
    s.Dispose();
    shootBody.Dispose();

    s = null;
    shootBody = null;

    vater.destroyShoot(this);
    return true;
}


Can someone give me the solution to delete objects from physicSimulator? THANKS

Sep 20, 2009 at 6:54 AM

It looks like you don't want the two geoms to collide since you're removing one, so you should return false at the end of OnCollision.

Sep 20, 2009 at 12:56 PM

No i found my error ... i dont used the PhysicSimulator.Remove method...

Coordinator
Sep 20, 2009 at 9:10 PM

Just as a reminder, remember to remove both the body and its attached geometry. Removing a geometry only will leave behind the body.