# Timesteps and "timesteps"

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

## Recommended Posts

Does anyone know a way to "hack" a different timestep under the current timestep?
I know It doesnt seem logical at first, but I remember something done with looping in a fixed update. And then basically damping the resulting values with variables found in the loop. I dont remember how its actually done, but does anyone know the name of this method and can guide me how to use this?

The main reason I ask this is because I have a simulation running at 50hz (1/0.02)
But id like to run some calculations in 1000hz (1/0.001)

Basically I'm simulating car physics, the driveline calculations work well at 50hz, but tires not so well. They get really jerky at low speeds, it seems to be the hardest topic in car simulations.

Anyway I'd like to run slipAngle and slipRatio calculation at 1000hz. I found that SAE methods work pretty well at 1000hz, not perfectly, but  good enough to keep the car 100% static at full stop.

Or if I dont need a different timestep, then could anyone give me some pointers on how to damp the slip calculations at low speeds? Switching to a velocity based friction model didnt give any good results. I had some notable side effects.

Also as a side topic cold anyone simply explain how's Runge-Kutta working and is it any good or it's out dated?

Thanks!

##### Share on other sites

I am not familiar with the challenges of writing car physics, but I would try to find a more stable integrator.

What is "SAE"?

##### Share on other sites

Is your time integration explicit? If so, you may want to try an implicit method. Though implicit is more computationally expensive, you can get away with much larger time steps, so in practice it tends to be faster. The downside is its more complicated to implement.

Runga-Kutta is fine, you can do it implicit or explicit. It is still widely used in computer modelling. The wiki page on RK is pretty good.

##### Share on other sites

I am not familiar with these type of physics too but this can be useful.

##### Share on other sites

Drop the Runge Kutta 4th order integration method! Yes, it does an excellent job at preserving energy, and no, it's not very good for game physics. Instead, use the symplectic Euler 1st order or Verlet 2nd order. Alternatively, use impulses instead of forces and drop the integrator completely, which gives the same result as symplectic Euler.

Cheers,

Mike

##### Share on other sites

I agree with h4tt3n. Drop RK4 and go with Euler.

Like I said this can be helpfull even if you're not using RK4's method.

##### Share on other sites

A simple approach that I've used in my games is:

lagTime = 0;

while (isActive)
{
frameTime = getFrameTime
lagTime += frameTime;
dt = constant frame rate;
while (lagTime >= dt)
{
integrate(dt);
lagTime -= dt;
}
}

##### Share on other sites

I should just point out to anyone reading this, Runga-Kutta is a family of methods. RK4 or, 4th order Runga-Kutta, is very common but just one method in the family. As other posters have implied, 4th order accuracy is overkill for a game. But that doesn't necessarily rule out the whole family of methods.

##### Share on other sites

I should just point out to anyone reading this, Runga-Kutta is a family of methods. RK4 or, 4th order Runga-Kutta, is very common but just one method in the family. As other posters have implied, 4th order accuracy is overkill for a game. But that doesn't necessarily rule out the whole family of methods.

Correct, it's a family of methods, not a single one. Should be mentioned. But my opinion is similar with the other members. I have implemented 2nd and 3rd order RK just once and never used them again, since they either introduced or removed a lot of energy from the system and generally did a poor job.

A few years back I tested a lot of integrators in the hopes that they would improve my simulations greatly above the standards of symplectic Euler. Well, I was mostly disappointed. The only two exceptions are the 2nd order velocity-less Verlet and the family of higher order integrators by David Whysong. These are just awesome, and I use them mainly for high accuracy space physics. If you want energy preservation, these 4th, 6th, and 8th order integrators will definitely do the job:

http://www.projectpluto.com/symp.cpp

Cheers,

Mike

Edited by h4tt3n

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015743
×