Detect sliding on a slope

Topics: User Forum
Jun 7, 2012 at 3:01 PM

Hi,

I'm new with Farseer Physics.

I try to detect when my body's player slide. How can I do that ?

I would try with the normal vector of edge but I don't know how can I get the right edge under body's player.

 

Thank's a lot

Jun 7, 2012 at 7:11 PM

You can shoot a ray in the direction of gravity (World.Raycast()) and find the closest edge like this together with the normal. Or use contact listeners find the fixture and calculate the normal. Or use sensors.

As for sliding depends how you define that in physics terms. Sliding motion is just frictional motion between two surfaces that are touching but I suppose you want something different. In other words you might want to find out whether you body positioned on an inclined slope is moving downhill because of gravity taking into account all other forces acting on the body like player input, friction, joint motors, collisions etc. This should be resolved in your game logic and could be as simple as finding whether the angle of the velocity with gravity is negative and the player has not issued any commands for moving downhill. 

Jun 8, 2012 at 9:36 AM

Thank you very much for all your advices !

I tried with the velocity vector, and it works wondurfully !