Crush

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Stevemata
Posts: 33
Joined: Sat Mar 17, 2012 11:11 pm

Crush

Post by Stevemata »

What would be the best way to determine if the player is being crushed by an object?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Crush

Post 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.
Post Reply