Detecting rigidbody "bounces" using Listeners

Detecting rigidbody "bounces" using Listeners


I've recently developed the need to detect when one rigid body bounces off of another so that I may, for instance, play a sound. I didn't see any already existing questions asking this so please excuse me if I actually missed them.

I've watched the Youtube HavokEnthusiast videos and have seen actions used to handle per-object behaviors. This made me think to check out more of the available demos, and there I saw listeners.

Listener callbacks seem like the way to go. The Users Guide Manual (the help file, not the pdf) lists quite a few listener types however and I'm not sure which to use. Is hkpWorldPostCollideListener the correct type to use for this?

What would be the simplest way using Listeners to detect when a rigid body has bounced off of another, and hasn't simply collided with it (where it could actually just be resting on it)?

Thank you for your time.

3 帖子 / 0 全新


It sounds like you're looking for a hkpContactListener.
Check out the demos in Demos/Physics/Api/Collide/ContactCallbacks/...


Thanks! Those demo were exactly what I was looking for.

I ended up using Demos\Physics\Api\Collide\ContactPointCallbacks\EndOfStepCallback.

The code provided for the hkpContactListener derived class gives you the ability to detect when a collision has happened once (like the bouncing spheres shown in the demo).