There are no random numbers in the engine and everything is calculated the same way. How can it happen differently each time?
This is on my own small physics engine that I made earlier that is written in lua and runs in the Moai SDK
There are no random numbers in the engine and everything is calculated the same way. How can it happen differently each time?
This is on my own small physics engine that I made earlier that is written in lua and runs in the Moai SDK
Use the same time steps every time. My physics engine is set to use 33 ms time steps, and I can produce the exact same simulations that way (assuming I use the same machine.) If I use different time steps, even 1 ms more, the game will slowly diverge.
You can do this with this basic loop:
void update( long timeMS ) {
_accumulatedTime += timeMS;
while ( _accumulatedTime >= _timeStepMS ) {
// do physics simulation
_accumulatedTime -= _timeStepMS;
}
}
This will ensure that you always run your physics simulation with exact time steps, and will also ensure that you never lose any time.
Read here for a good explanation of timestep http://gafferongames.com/game-physics/fix-your-timestep/ Timestep should be fixed, and this article takes a good approach and explains everything clearly.
This is difficult to answer without more details regarding the engine itself. My hunch, however, would be to look for race conditions in your code.
The kinds of details that would be useful include: