I'm trying to wrap my head around how and when to update an entities position.
My game loop updates logic at 25 FPS and renders at 50-60 (Depending on the computer hardware).
So lets say I'm moving an object from 0 to 75 over a course of 100ms. In my update logic, should I update the position based on a per frame value or a per second value?
I was doing the math, and came up with and interesting find.
Since the update function updates at a rate of 25 fps, this means that it will be called at 40ms, 80ms and 120ms.
And the render function updates faster at a rate of 60 fps (for the sake of argument), which means it will be called at 16, 32, 48, 64, 80, 96, and 112ms
So if you line up all of these events on a timeline you'll notice that at the 6th render (96ms) the value of our position would be 72. And on the 7th render, the position would be 75.
Then the update function would be called at 120ms and would notice that the value is 75, but the current time is 20ms over what it should be.
Now I know that 20ms isn't much, but how do you compensate in collisions, physics, and AI for this? Should I instead update my values per frame instead of per millisecond?