Handle deltaTime discrepancy

Hey all!

I was working with a game that was working smoothly with a fixed value for position change, but as soon as I multiplied it by the deltaTime I notice that sometimes the player movement flicks.

Digging deeper on it I realize that what is happening is that Im getting a somewhat constant value for deltaTime of 16ish then out of sudden on the next frame it is 36, the frame after is 1, and then it got back to the normality of 16, this is causing that on the frame with 36 the player mover a lot more than when the value is 16, then it moves almost nothing when it is 1 and then it moves at the normal speed, but that sudden high then very short movement makes the flick impression, I’m not sure how would I be able to handle that, not sure either if babylon has something already built in to handle that.

Got some answers from ChatGPT btw, but wanted to check here before cause I’m pretty sure that I’m not the first one to have that issue and GPT solution wasnt exactly what I expected :sweat_smile:

You may have a look how fixedDelta realized in this Time class - https://playground.babylonjs.com/#1CZ9VY#5
But since fixed value works for you already probably there is no need to use deltaTime?

1 Like

Got you! Its way different than what ChatGPT provided! I’ll give it a shot! Thank you!

About the fixed value, I tested it only on my machine, so it would probably be a issue on other computers… :confused:

1 Like