All posts tagged interpolation

This week I’ve made massive progress within the network of my game. I started this week with fully implementing the entity interpolation. What it does is smoothing out everyone else’s movement, this is important since one only get fragments of data which results in very ‘jumpy’ position if not handled correctly. So when I’ve received two or more updates (I have a lerp time on 100ms, updates being received every ~50ms) one can take out positions in between the updates which leads to smooth movement.

The next thing I worked on was client-side prediction. This is for making you feel in control of your own character, actually simulating the actions before he receives validation from the server. This is important because it is annoying to feel that one’s input is slightly off when looking at the time between pressing a button before something actually happens on the screen. So by starting to move the ship before receiving answer from the server this is solved.

The prediction causes a problem though, because it’s just a prediction. So I had to introduce something called correction / movement-correction in order to make sure that the client and server actually were on pretty much the same positions. This is done by every time an update is received from the server the client looks at what input number/sequence the verified update had. By using the correct positioning from the update, he can apply all newer, non-verified input after that to get another, more accurate, predicted position. He saves this position as a target and will move towards it every update. This makes the client’s predicted ship end up on the same track as the one the server is simulating for it.

No pictures on the updates, the game look like it did at the last pictures except the movement is much smoother. The core network is pretty much done and I will hold on extrapolation, because for now I don’t feel like it is needed. So I will focus on the entity system and how to render text for now.

I’ve started working with the interpolation but it’s not yet working, so I will continue working on that this week too.

Last week I lost a couple of days and got behind schedule. I was supposed to implement the entity system and improve in the player ships, but now I have to do that this week instead. This shouldn’t really be a problem squeezing in in this week’s schedule but I know some days will go missing this week as well.

Anyway this week I will continue the work on interpolation. When that’s done I will focus on the player ships, entity system and then start looking into text rendering.

Oh the time synchronization.. Yes I encountered this problem too when I started implementing entity interpolation.

So basically I wanted to interpolate entities between positions but in order to do that I first need a synchronized game time. This is due to the server will set a time stamp on every update snapshot. And in order to determine where between the snapshots the entities should be rendered clients need to have the same game time as the server.

I am synchronizing the clients game time when he connects. I used this article to implement this Clock Synchronization of Client Programs,it works like this:
The client sends a join request packet to the server. The server determines that the game version etc. is the same then it starts sending time synchronization request packets to the client, whom replies with time synchronization replies as fast he receives a request. After 10 of these requests and replies I have some ping time samples. By sorting out some samples that were way off the normal and taking a mean value of the remaining the server can approximate the average ping time for that client. So he then sends a join accepted message containing the clients information including game time and ping delay, working as game time offset.

Now I can finally start working with the interpolation!