I am actually not convinced about that way of doing thing from that link. Explain me this, quoting the article:
Quote
Interpolation and Prediction
Like I said the game code runs on it’s own frames per second, so when you draw/render your frames, it is possible that it’s in between 2 gameticks. Let’s say you have just updated your gamestate for the 10Th time, and now you are going to render the scene. This render will be in between the 10Th and 11Th game update. So it is possible that the render is at about 10.3. The ‘interpolation’ value then holds 0.3. Take this example: I have a car that moves every game tick like this:
position = position + speed;
If in the 10Th gametick the position is 500, and the speed is 100, then in the 11Th gametick the position will be 600. So where will you place your car when you render it? You could just take the position of the last gametick (in this case 500). But a better way is to predict where the car would be at exact 10.3, and this happens like this:
view_position = position + (speed * interpolation)
The car will then be rendered at position 530.
So, following the logic above, interpolation regulate how much speed we apply to the position of our object. But notice this is not per second, but between 2 game updates, which is in 40ms time.We are applying the speed to the object 25 times every second. I would think that the logic thing to do for the car example above would be to specify the speed traveled in 1 second or something and then multiply by DeltaTime, but if I where to do that, now for it to work I would need to pass:
view_position = position + ((speed * UpdateDeltaTime) * Interpolation);
Correct me if I am mistaken.
The first "position + " would be the current position let's say for the 10th update, and "(speed * UpdateDeltaTime)" would be the speed traveled in an update time (40ms), and then " * Interpolation " that range from 0 to 1, to blend between the predicted position on the new update. And this if I want Speed to rapresent something concrete like how many pixel are traveled in 1 second time. Otherwise I need to rely on some tiny arbitrary value, if following the original example from that link.
This now looks fishy because I am updating the object in one way and drawing it in another, it really increases a lot the opportunity for mistakes (unless I abstract it in some method that compute the right resoult for an arbitrary variable without me manually messing with interpolation and dt)... Is anyone actually doing this?! Or I am just blindly following some questionable advice?!