Is there a way to detect how hard an object was hit during a collision. I have been experimenting with the PhysicsSkin_callbackFn and checking the old and new position of skin0 but I am not at all sure if thats the right thing to do.
What I do to figure out whether to play a crash sound (and if so how loud) is to look at the change in velocity between two frames. If the change is large, then it's a hard impact.
You can also look at the velocity difference of the contact point on each body to calculate how hard the hit is. Note that you need to get the velocity of the point, and not the body, to account for spinning speed.
Just get a compare on the velocity. Jwatte goes above and beyond with taking spin into account. That is definitely more accurate, but i just get velocity of body (lazy, don't care that much) , and i still get predictable stable results.
I use it for two things, one, impact, like you want, and also, i have a part in my game where a player can ride a swinging vine, and i do the velocity compare plus a little scaling to decide how far to throw the player once they let go.
Jwatte has a habit of being right.
The physics engine obviously calculates this internally, but does not expose it at the time of the event (the only time it matters). I tried reading into the code for the collision checking, but it made my head hurt.
Oh, Jwatte, thanks for the SAP system.