I'm creating a tank game using jiglibx, and my tank's shell round is a basic physics capsule.
I'm trying to catch what it impacts, and delete/remove it after the first collision.
Here is my code:
//I've declared this globally
private PhysicObject physObj;
//This is in the spawn function
physicObj.PhysicsSkin.callbackFn += new CollisionCallbackFn(PhysicsSkin_callbackFn);
bool PhysicsSkin_callbackFn(CollisionSkin skin0, CollisionSkin skin1)
DrawSmokeAtHit(skin0.NewPosition); //the place where the tank shell collides.
physicSystem.RemoveBody(physObj.PhysicsBody); //This line causes the error
However doing this, I get an index was out of range error in the DetectAllCollisions() method in CollisionSystemSAP.cs … specifically in AddToActive(skins_[i], skinTester_);
What is the proper way to remove a physics object so it doesn't stay in memory?