🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Sending 'command duration' from client to server

Started by
0 comments, last by Christopher Crain 9 years, 3 months ago

I am making a client-server multiplayer game, where the server has the authority.

I am currently at the point where I must implement client-side interpolation.

The client sends Input packets to the server. Each has a unique ID, which are increasing.

The server responds with WorldState packets. Each has an ID which corresponds to the ID of the latest input packet processed.

Now when the client receives a state update, it needs to interpolate beginning from the latest received state and apply the inputs that have not been acknowldedged yet by the server.

According to this, each input command also contains its duration in milliseconds (I haven't implemented this yet).

The client can have a button pressed for some duration.

So when button A is pressed an input packet is sent with the button_a flag set to true.

When the button is released another input packet is sent with the button_a flag set to false.

My questions is:

Is the way I handle inputs correct? Because the way I am doing it, if one of the packets takes more time to arrive than the other one, the server will apply input for more or less time than the actual duration of the command.

Also, how can I measure command duration this way? -- I need this for client side interpolation. The way I do it, command duration does not make sense for the button press, only for the release.

What I could do is not send a packet when the button is pressed but only when it is released. This way I can measure the milliseconds for which it was pressed and send it as one command. But this has the downside that if the client presses a button and does not release it for a long time, the server will receive it with a big delay.

Or maybe instead of sending the command duration I could send the number of seconds (milliseconds included of course) elapsed since the game has started? This way it will be easy calculate the command duration if I am not mistaken.

So, what is a good way to handle inputs that can happen for a period of time?

Advertisement

This article helped me understand some of this process, I ultimately decided I didnt need this type of protocol for my RPG. But this may help you http://www.gabrielgambetta.com/fast_paced_multiplayer.html

This topic is closed to new replies.

Advertisement