Sliding Plane Collision Response | Stop Object From Sliding Backwards on Slope

Started by
10 comments, last by Gnollrunner 4 years, 9 months ago

I didn't use this paper but in any case here's what I do. At the end of your collision you get a contact normal, perhaps more than one.  I keep a list of all current "touches" at the end of the move.  To determine a "touch" I keep a sphere slightly bigger than the collision sphere. Anything inside that is touching. Then you just take dot products of all your current touch normals (usually one but for instance if you are standing in a little valley it could be more) and the up normal and see if any of them fall above a certain value. If so, your character is standing and you turn off gravity.  This way you will slide only when the surface you are standing on is steep enough.  If you want to get fancy you can have some sort of friction based on the dot product value and even the material you are standing on.  It's actually super easy to do if you already have everything else working. You don't need any ray casting and stuff like that.

Edit: after going back and reading more of the thread, I'm guessing you might be missing something. The contact normal(s) should be being generated somewhere in your code. I mean you need it to do the response.  So it's just a matter of finding it and then applying the dot product.  It should be super simple to solve this, so don't go hog wild implementing something new.

One a side note I had to do some extra stuff to implement double contact collisions which use a cross product.  I'm not sure if your code handles that already. However if you find yourself getting stuck in corner situations, that's something you might need.

This topic is closed to new replies.

Advertisement