Damage done by a collision

xwipeoutx
Posts: 9
Joined: Fri Mar 20, 2009 3:57 am

Damage done by a collision

Post by xwipeoutx »

I'm in the midst of creating a game where one sets up traps around their house to try and defeat a bunch of zombies that are attacking one's fridge.

The weapon I'm currently working on works as a magnet/metal ball thing - basically, you put some magnets on the ground, and some metal balls, and the balls are attracted to the magnets. When a ball hits a magnet, that magnet is disabled for a few seconds - which gives a really cool effect of the balls flying randomly around on the floor.

Anyway, i'd like to make it so the damage done to a zombie is proportional to the speed of the bullet, I can't figure out how to do it consistently.

I'm currently using the logic I explained in http://bulletphysics.com/Bullet/phpBB3/ ... php?t=3393 to do my physics - inside each simulation step, I loop through all the manifolds and dispatch them to my physics response class. My physics response class basically says "if i'm a zombie, and the other object is a ball, then i take damage equal to the ball's velocity" (which i store myself before i do each simulation step, so that i have the speed before the dynamics, which i need because otherwise i'd be getting the new speed).

Using some extensive logging, I've noticed that for what I see on the screen as 1 collision, it actually processes a plethora of contact manifolds. My initial guess is that the interpolation step doesn't refresh the contact manifolds, is that correct? I don't know how to check this myself, I'm a bit overwhelmed.

Even when I add a huge force in the opposite of the direction of the impact, so it just flies away from the zombie, it is still processed as several collisions.

I feel there's something I've missed...any help?

And as kind of a side note, are there any plans to add some kind of listening interface instead of (or in conjuction with) global callbacks?