Detecting if an objected is 'squished'

Topics: User Forum
Apr 3, 2009 at 5:25 PM
In older games (Mario, Sonic, etc.), when the character would get stuck between two objects, he would be 'squished' and killed.

I am looking to have a similar effect, but am not sure how to detect the squished condition in farseer. So far my thoughts are to have the object store a list of all objects it's colliding with, and if that list contains two or more objects capable of squishing the character, then killing him.
However, I also need to know if he's intersecting and stuck in an object, or just standing on top of it - I wouldn't want him to start dying because he's standing half over one ground and another, and registering collisions with both!

What is the best way to detect this in Farseer?
Apr 3, 2009 at 8:32 PM
Edited Apr 3, 2009 at 8:42 PM
Good question friend,
ive been thinking about this myself
my solution would be
check if the y force is greater than that of the gravity(negative y force), when objects land on top or squish down they will apply more force.
Im not sure if you can check how much force is being exerted on the object, i only know of checking the linear velocity,
but if you can check the force that should work.
YOu might wanna check for collision on the floor and check if the force is greater than a certain amount.
Apr 3, 2009 at 11:55 PM
You can also use Geom.CollisionCategories, like Cat1 is the floor and Cat2 is the squishing object. Inside OnCollision you check the category and decide if the player should be squished.
I think CollisionCategories plus the bodys force will handle that