Search code examples
iphoneperformancecollisionchipmunk

Check collision speed in Chipmunk Physics


I'm using Chipmunk 5 for iPhone, with Cocos2D. Upon collision between two specific objects I'd like to run a method which checks the velocity of that collision, if it's over x it runs one set of code, if it's under x it runs another.

Now, I understand the basics but I can't work out the code to run a method on collision detection, and the code to check impact speed.

Any help or pointers would be greatly appreciated.

Cheers.


Solution

  • Check out the addCollisionCallbackBetweenType function in SpaceManager.h That might help with registering collisions.

    After that, you can check the v property for the cpBody objects, a cpVect of the velocity. (http://code.google.com/p/chipmunk-physics/source/browse/trunk/include/chipmunk/cpBody.h, not linked, new user.)

    I am not experienced with chipmunk, but that's what a little googling turned up.