Fixed timestep update for physics / damping code?
I have a Component in which I need to run some physics related code. Specifically, linear damping but only on the X and Y axis and not Z.
I currently run the following code in the TickComponent():
But it is not framerate independent.
Is there a way I can run the above code at a fixed timestep?
asked Jul 05 '14 at 02:59 AM in C++ Programming
I think to get a fixed timestep, you would just wrap your damping code in a loop and use a static variable to track the elapsed time. It would look something like this (desiredTimeStep would be whatever fixed duration you want):
Let’s assume the following code gives the desired result with a fixed 1/60s timestep:
This effectively multiplies the
So what if
This gives you the following, framerate-independent code:
answered May 02 '15 at 11:02 AM
I think somethings wrong with your calculations, you scaling whole result where what you should just scale the delta values, so try this
answered Jul 05 '14 at 01:11 PM
Unreal Engine does not use fixed time steps, and cannot get deterministic behavior using the default physics integration. The best you can do is enable sub-stepping, setting some small sub-step size, and hope for the best. I have a simulation that definitely "hitches" when something takes away the machine for a few milliseconds :-(
To provide consistent (but still not 100% deterministic) behavior with variable time step, you'd have to use a Runge-Kutta-4 integrator, which is way too expensive (calculating all those derivatives) and also use swept collision detection across the board.
answered Jul 07 '14 at 12:02 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here