Reputation: 3766
I have a projectile and a tower. When i hurl the projectile it strikes the tower. Based on projectile force the tower is broken. Now I need to know how to get the force that is applied to these 2 object when they collide(not before collision, rather after collision). I know in the following method they are calculated-
void MyContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse *impulse)
{
force=impulse->normalImpulses[0];
}
this gives me the overall force applied, But i want to know the individual force applied to 2 different object.
And another question , this method reside in the subclass of b2ContactListener class. How to pass this value to gameScene where object will be destroyed.
Upvotes: 0
Views: 1694
Reputation: 8272
The same impulse is applied to both bodies (in opposite directions of course).
You will need to have a variable which is visible to both the PostSolve callback and wherever else you need to use it - a global or class variable could be used.
Upvotes: 1