I am beginner too. But now we have a lot of very basic tutorials but we do not have another tutorials. If you think input prediction in not perfect than make a tutorial about better solution. Because every beginner do no want to have this problem (I copied it from the tutorial above)
Important Networking Concepts
We have mentioned this before now, so lets take a look at what exactly it entails. In a naive approach to networking, you might try the following model:
- Client presses the right key, tell the server
- Message arrives at server sometime in the future ( 200ms latency )
- Server sends back the new position to the client
- Message arrives at the client ( 200ms latency )
- Client updates their position 400ms+ later.
This approach might work well over LAN connections where the latency is really low, but when connecting players to a server via the Internet, latency can be anywhere from 30ms to 800ms - rendering the game unplayable because of the delay. When you push a key the response is so badly delayed that it will not be a very good game to play at all. But how do we solve this?
Client prediction is the solution, and simply means acting on input immediately, predicting what the server will calculate as well. We apply input with the assumption that your results and the server results (whenever they arrive) will be the same. When a client presses the right key twice, and ends up at
x = 2 , the server will arrive at the same conclusion and tell you 600ms later - you are still in the correct place.
This is important for immediate feedback on the client side, and even though updates are running via a server, the client positions should match up.