correction

All posts tagged correction

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.

Now the week is over and on Monday milestone 2 is due. At this milestone we are to deliver a proof of concept, something that shows that our projects are viable.

Since last post (Tuesday) when I had some working movement I have been working on moving the ‘moving’ part to the server instead of the client. What I had was the client moving his ship, sending the position to the server who them forwarded it to everyone else. This is called client authority since it’s the client that determines where he will move, this allows people to modify the client or its packets in order to cheat. What I want is server authority where the server does all the moving of the players, all the clients does is sending their input. So this is what I’ve implemented, I have the clients generating input about 30 times each second. These inputs are sent to the server about 20 times each second (only the new ones are being sent). The server applies the movement and tells everyone of the position in the next update.

For feeling more in control of your own spaceship I have some client-side prediction, where your ship moves directly at your input without waiting for the server to answer. But because this is only a prediction the movement can go wrong and has to be corrected, we must do that too. So we keep a buffer with previous inputs so when the actual position we got from a certain input is returned, we simply correct our movement at that input, then apply all newer inputs after that which gives us our new predicted position.

This is what I have for milestone 2, a game supporting 4 players over the network, with server authority, some client prediction and movement correction.