Collision and safty remove?

Sep 19, 2009 at 6:45 PM


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[];".

Here is my Code:

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

    s.OnCollision -= OnCollision;

    s = null;
    shootBody = null;

    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...

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.