Jump to content
  • Advertisement
whitwhoa

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

Recommended Posts

Posted (edited)

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.

Edited by Gnollrunner

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!