Joint Breaking / Collision

Topics: User Forum
Jan 11, 2010 at 2:35 AM

Hey guys, I have a quick question.  First off, I've looked around quite a bit and don't really understand how to use OnCollision.  Secondly, I'm using the Ragdoll from the SimpleSamples, and I want to be able to break some of the joints based on where I shoot it (the ragdoll).  I gather that I have to do something with the collision (the bullet and the ragdoll, or part of it), and then break the joint in the ragdoll.  I have no idea how to do this or how to get started, so any help is greatly appreciated.  Thanks!

Jan 11, 2010 at 2:42 AM

OnCollision is a delegate. You assign and handler function to it, like so

Geom.OnCollision += MyCollisionHandler;

MyCollisionHandler looks like this

bool MyCollisionHandler(Geom geom1, Geom geom2, ContactList contacts)

{

return true;

}

 

It will be called once every update for every Geom this geom collides with. There's a lot of information you can use in the contact list, but for detecting when a bullet hits the player, all you need are the geoms.