Skip to main content
gamedev.net
🔒 Locked

Stepping through time...

Started by Sweenie 1 reply 1.2k views
Original Post
Sweenie
Sweenie
Hi. Most physicsimulations out there advance through the simulation by small steps.(ODE for example) What is the best way to make a loop that makes sure the physics runs smooth and at a constant and realistic rate. What should the stepsize be and must I lock the framerate(Framelimiting) to achieve this? And is framelimiting a good idea?, wouldn''t that be a "waste of pace"(oh, that one was bad) for fast computers? I would be very thankful if someone could show me or point me to a place there I could see a codesnippet of a "correct" "physics loop". //Sweenie
<-Sweenie->
minorlogic
minorlogic
Just keep physics calculations separate from a visualization.
So for e[ample frame rate can be 100 fps, but physics time step 1/30.
zerotacg
zerotacg
Get the delay wich past from the last physics done until now
and use it as timedelay in the physic-simulation, maybe multiply it with a factor so thats looking realistic.
This way you get a good looking physics wich becomes more exact with higher framerates.
Another good thing is to calculate the time delay like 1/delay if the delay is above a certain value you than have to multiply it with a value so that the timedelay at the bordering delaytime is the same value as short above, this way the simulation is getting very slow but still smooth if the framerate drops.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.