Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Client / Server Refresh Rate

Author
Message
Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Apr 2013 01:48
Hey,

I'm making a client / server system and would like to know the optimal refresh rate (How many times do you send your player position to the server per second)

It seems to be a delicate balance between lag and jitter...

-Matt

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Qqite
16
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 2nd Apr 2013 02:37 Edited at: 2nd Apr 2013 02:40
First of all, make sure that when the client gets an update to where the other players are, they they do not just "jump" there. Make it so that you have two separate variables for where the player "is" and where the player "should be" so that it can gradually fix its position over the course of a few frames.

After that, you only need to update around 3-5 times a second. Maybe a bit more if you feel you want to. But if you have the system above, you really don't need any more than that.

If you are planning on make a mass player multiplayer game (25+) then I would strongly against going any higher than 5 times a second.

Btw, little tip: Design the packet to tell when the player has stopped and then don't worry about sending another packet until the player does something. This isn't really necessary but is a nice touch to save a lot of bandwidth for players.

Ventures of the worlds around us are limited only by our imagination.
Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Apr 2013 04:00
Thanks for the help

I haven't created any multiplayer games, so I don't know much of the theory, but I have been thinking of adding a system similar to this

Are there any other optimisations that I could add?

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Apr 2013 10:22
It depends. What game are you making?

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Apr 2013 13:10
Have you heard of realm of the mad gods?

It's going to basically be a realm of the mad gods style pvp arena

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 2nd Apr 2013 14:06
Quote: "First of all, make sure that when the client gets an update to where the other players are, they they do not just "jump" there. Make it so that you have two separate variables for where the player "is" and where the player "should be" so that it can gradually fix its position over the course of a few frames."


Why not go further and implement movement prediction. Don't slide the player into place after an update, instead put him there and slide him to where you think he is moving to. (Calculate his angle and speed)

This is a principle John Carmack used when trying to improve the networking design of Quake2 back in 1998. This was built into Quake3.

Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Apr 2013 14:38
Wouldn't this be the same speed though? You would still have to send the real position afterwards to make sure the prediction was correct...

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 2nd Apr 2013 15:18
What happens is if you use prediction, you can fluidly move other players each frame, and you can minimize lag jitters since if there is lag the player keeps moving fluidly in the direction he was heading. Ideally when the player sends his updates as you discussed above, he is close to the predicted position and jumping is limited.

Problems arise when lag jitters turn into massive lag spikes. The player keeps moving in one direction until finally the update comes or the player is disconnected. So sometimes it's best to time limit the prediction. This is an extreme case but worth mentioning.

Movement prediction is probably the best method available. You can reduce lag jumps and you get to have per frame movement.

Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Apr 2013 16:17
OK I'll look into it

Thanks for the help

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Apr 2013 17:03
Source posted a nice article on networked FPS games.

In it, it was explained how to use prediction methods to make the players move smoothly. They used cubic interpolation, which means you'll have 4 positions stored for every player, each from a different frame.

When sending packets, you don't simply send the current data. What you do is you accumulate multiple frames of the game into one package, and then send it. The client has to unpack the package and try to interpolate between the many frames contained within. The result is that you never leave out a game frame.

The article also addressed the issue of lagged response. If you shoot a player, by the time that information arrives to the server, the player you shot at will not be there anymore.

The trick is to time-stamp every frame. This allows the server/clients to "undo" a few frames, go back in time to when the bullet was fired, and check if there was any collision or not.

Happy coding!

TheComet


Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 2nd Apr 2013 17:14 Edited at: 2nd Apr 2013 17:22
you have to calculate the stuff u send from server your self..

lets say your Uploading speed by the server is 500KB/s
now, calculate..
Integers of X,Y,Z postiions + Y rotations is (4 bytes * 4) = 16 bytes for each person.
so..
that means, if u have 200 players online, it will be about 13KB for sending.. if u send it 3 times per second, it will be about 39KB/s out of your server's bandwidth.

thats the basic calculations you have to do.
now, how about PING command that server needs to send to check if the client alive, or chat system.. or more..

personally, i suggest sending new coordinates 2 times every second to a clients. make a smart system at the client side that recives those new coordinates, and smooth moving them from OldX,Y,Z to NewX,Y,Z positions.

Advanced Updater for your games!
Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 2nd Apr 2013 18:12
Thanks for all the help guys

I like the idea of backtracking for hit detection... I'll have to plan this through.

As it is only a simple 2D top down game, at the moment it is working fine sending every 250ms and smoothing out the movement, but i may have to upgrade this to a movement prediction system in the future, or sending every 300ms but with 3 different movements...

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330

Login to post a reply

Server time is: 2026-07-06 20:51:55
Your offset time is: 2026-07-06 20:51:55