float dt = (time between last frame and this frame measured in seconds); acceleration = 9.8f; // NOT += velocity += acceleration * dt; position += velocity * dt;If you want to force your physics to use 60 FPS, you can hardcode:
const float dt = 1.0f / 60;
If an object is on the ground, you have (at least) two choices:
- Disable the gravity code so that the object isn't pulled through the ground
- Resolve the collision with the ground every frame. The object will bounce if you have restitution > 0 or "stick" if you have restitution == 0.