Hi,
I'm was wondering whether this is a common/known problem when developing a realtime (fast paced) multiplayer game:
I have a ball on the client side and server side. If I press the forward key, the ball on the client side received an impulse (1 time applied). This input is sent to the server which also applies the input to the ball on the server.
I notice that the ball on the client is ahead a little bit (due to the latency from the input that was sent to the server) and I expected this.
I see the ball rolling on the client (still moving) and let's say that this is 50m from the starting point. I see it on the server at 40m.
Here is my problem: if I know press the down key arrow to move back, I see that my client is at 45 meter after a while but my server never reached the 50 meter point, and is now at 30 meter.
I was wondering how to exactly fix this kind of problem. I think that there is something wrong with my implementation of applying impulses, which is implemented like so:
- Once a key is pressed/released, an input struct with the keys that are pressed/released is being sent only once to the server (if each individual key is pressed/released, the struct is changed and 1 signal is sent to the server).
- Locally, I have a loop that runs 10 times a second for input: it checks based on the input struct which keys are pressed and applies the impulse accordingly.
- On the server I have another input loop (also 10 times a second). Once an object has been received, the loop applies the forces again depending on the input structure.