Hi Developers,
i am using spacemanager and i want to calculate the force with which the objects collide so that i can adjust the sounds and appropirate spirtes depending on the damage. can some one tell me how to calculate the forces. here is the code i got on this site.
if(!cpArbiterIsFirstContact(arb)) return;
cpFloat impulse = cpvlength(cpArbiterTotalImpulse(arb));
float volume = MIN(impulse/500.0f, 1.0f);
NSLog(@"impulse is :%f",volume);
NSLog(@" impluse x:%f y:%f", cpArbiterTotalImpulse(arb).x , cpArbiterTotalImpulse(arb).y);
if(volume > 0.05f){
[SimpleSound playSoundWithVolume:volume];
}
i have this in my POSTSOLVE method.i tried it in BEGIN aswell and all it prints is 0. i went through this site and found that i needs to do this.
smgr.space->elasticIterations = smgr.space->iterations;
even after doing the above , sometimes i get 1 and some times it says "nan". is there something basic i need to know?
Thanks