• ### Popular Now

• 11
• 9
• 10
• 9
• 11

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

## 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) {
physicsComponents.get(i).Collision(normal);
}
}


Collision(normal):
public void Collision(Float3D normal) {
}


Updating the physicsComponents:
if (mass!=0) {

acc = gravity.Clone();
}


##### 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 on other sites
Could you explain to my the algorithm of the "sweep test"? I was trying to read it but i dont understand how to do it? (for spheres)