Page 1 of 1

Crush

Posted: Thu Jun 21, 2012 7:14 pm
by Stevemata
What would be the best way to determine if the player is being crushed by an object?

Re: Crush

Posted: Thu Jun 21, 2012 7:27 pm
by Norbo
One option would be to cycle through the character.Body.CollisionInformation.Pairs collection, examining the pairs' Contacts lists. The NormalImpulse in the contact refers to how much impulse was applied in the previous frame along the contact normal.

The absolute value of the NormalImpulse depends on a variety of factors, but checking it against some high fixed threshold would probably be good enough to detect crushing scenarios.

The simplest implementation of the above (if any impulse exceeds threshold, consider character crushed) would consider an extremely hard impact to be 'crushing,' though. This effect may work out in the end since getting walloped by a boulder is painful even if you don't get smushed up against a wall.

To find only true crushing conditions, look for contacts with opposing Normals with large NormalImpulses.