Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Modelling Sliding as continuous collisions

This topic is 5455 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to create a very simplistic physics model that only takes into account an object''s thrust, gravity and the ground. The gravity and thrust are expressed as vectors, and every frame I basically just add the two together (the thrust is the direction the player wants to take). Every frame, I add these to the Delta of the player and then add the delta the player position. So, if you thrust forwards for a while you end up going very fast, then if you turn around and thrust the other way you slow down (and eventually start accelerating in the opposite direction). The problem is with the ground. If the object is falling onto the ground, I can get the normal of the ground at the point of impact and reflect the delta around that normal, and that works fine - looks like a perfectly elastic collision, which is great. However, if you are sliding along the ground then there is theoretically a constant impact with the ground (because gravity will always be trying to pull you into the ground while the ground rejects that action), and this is causing me problems because the object jitters and occassionally freaks. I want to try and keep the model as simple as possible, which is why I want to use a collision for sliding behaviour - I don''t have to use seperate code paths for different movement methods. Is this possible and I''m just missing something pretty obvious, or should I abandon it and do the seperate code path route? p.s. I figure that if I make the collisions inelastic later on and get this working, it should neatly solve/approximate friction too.

Share this post

Link to post
Share on other sites
you''ve got to reflect the velocity and cancel the force (thrust + gravity) along the ground normal.

F = Thrust + Gravity;
V += F;

float elasticity = 0.2f;
float friction = 0.3f;

if (collide_with_ground)
Vnorm = (V * Nground) * Nground;
Vplane = V - Vnorm;
V = Vplane * (1.0f - friction) - Vnorm * (1.0f + elasticity);

F -= (F * Nground) * Nground; // remove the force along the ground to stop the object jittering.


that way, you won''t have an extra force that keep pushing your object down to the ground, no matter how hard you push down.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!