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) {
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();
}