Jump to content
  • Advertisement
Sign in to follow this  

Jumping instead Sliding

This topic is 3216 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'm programming a physics engine for a racing game. I'm using sphere terrain intersection. I trying to test it by using spheres over a terrain. The result is that the spheres are jumping instead of sliding along the terrain. What to do? checking collision...
for (int i=1;i<physicsComponents.size();i++) {

iCollisionObject sphere=physicsComponents.get(i).GetNextCollisionObject(fps/30);
//iCollisionObject sphere=physicsComponents.get(i).getCollisionObject();

Float3D normal = cground.IsTouchingN(sphere);

if (normal != null) {

public void Collision(Float3D normal) {
movementForce.AddToThis(normal.Multiply(-1f * movementForce.Length()));

Updating the physicsComponents:
if (mass!=0) {
setPosition(position.Add(movementForce.Multiply(1f / fps)));
movementForce.AddToThis(acc.Multiply(1f / fps));

rotation = rotation.Add(rotationForce);

acc = gravity.Clone();

Share this post

Link to post
Share on other sites
Don't really get what your doing at the moment, detecting a collision then just pushing them apart?

This explains how to do collisions with sliding:

it uses ellipsoid space but if your only using spheres then it will be much easier. If you don't want to use sweep tests for all your collisions then you could do:

Store current position
move object
check collisions
if no collisions, done
else move object back to previous position
preform sweep test + sliding

Share this post

Link to post
Share on other sites
its been over a year since I read it so I'm not entirly sure myself now. If you check his original paper http://www.peroxide.dk/papers/collision/collision.pdf he has the code int he appendix at the end.

As for using spheres, instead of putting seperate values for the Ellipsoids (x, y, z) just do (radius, radius, radius). Once you get it working for a single triangle its simple to loop through all your faces (cull as needed) to find the closest collision.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!