Forum ‹ Games ‹ Client runs faster than server
5 posts
• Page 1 of 1
Client runs faster than server
Hi.
I am new to multiplayer games but I have read the guide on this forum and I have also read a other guides on the subject.
So far I have a super simple asteroids clone. I have a game loop on the server that handles all the movement and recieves input from the clients. The server sends state updates at regular intervals and the clients use interpolation to create a smooth movement and this works nice.
But when I try to add prediction into the clients loop algorithm I notice that it runs faster than the servers physics update 30 fps, even though my flash is running with 60 fps, but physics are locked fps at 30. Thus the server falls behind very fast even though its supposed to run with the same period. Now, I didn't expect them to run perfectly synchronized, but the client runs 1.5 times faster than the server.
What is the proper method to solve this issue?
/thanks
I am new to multiplayer games but I have read the guide on this forum and I have also read a other guides on the subject.
So far I have a super simple asteroids clone. I have a game loop on the server that handles all the movement and recieves input from the clients. The server sends state updates at regular intervals and the clients use interpolation to create a smooth movement and this works nice.
But when I try to add prediction into the clients loop algorithm I notice that it runs faster than the servers physics update 30 fps, even though my flash is running with 60 fps, but physics are locked fps at 30. Thus the server falls behind very fast even though its supposed to run with the same period. Now, I didn't expect them to run perfectly synchronized, but the client runs 1.5 times faster than the server.
What is the proper method to solve this issue?
/thanks
- tef
- Posts: 10
- Joined: January 7th, 2011, 3:38 pm
Re: Client runs faster than server
I highly suggest that you switch to a frame rate independent mode. Ie, instead of using frames you calculate the offset since the last tick and calculate the world changes based on the difference.
The subject is a bit complex to get into at first, but it's really worth it in the long run as it also fixes issues such as different computers running your game at slightly different speeds. If enough people are asking for it, I will write some tutorials on the subject!
The subject is a bit complex to get into at first, but it's really worth it in the long run as it also fixes issues such as different computers running your game at slightly different speeds. If enough people are asking for it, I will write some tutorials on the subject!
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 808
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Client runs faster than server
The game is not dependet on flash frame rate. The physical update has a fixed frame rate, so even though flash doesn't manage to keep its frame rate the physical frame rate will always be forced to 30 fps, ie. 33 ms per period. But flash will draw as many times as possible during that period.
Maybe I need to do something similar on the server side, or use offset time as you suggested. Now my server game loop is just a timer. I guess the fram rate can't be trusted on the server side either?
AddTimer(delegate {
ForEachPlayer(updatePhysics);
}, PERIOD);
Maybe I need to do something similar on the server side, or use offset time as you suggested. Now my server game loop is just a timer. I guess the fram rate can't be trusted on the server side either?
AddTimer(delegate {
ForEachPlayer(updatePhysics);
}, PERIOD);
- tef
- Posts: 10
- Joined: January 7th, 2011, 3:38 pm
Re: Client runs faster than server
tef wrote:The game is not dependet on flash frame rate. The physical update has a fixed frame rate, so even though flash doesn't manage to keep its frame rate the physical frame rate will always be forced to 30 fps, ie. 33 ms per period. But flash will draw as many times as possible during that period.
Maybe I need to do something similar on the server side, or use offset time as you suggested. Now my server game loop is just a timer. I guess the fram rate can't be trusted on the server side either?
AddTimer(delegate {
ForEachPlayer(updatePhysics);
}, PERIOD);
Nope there is no guaranteed processes speed on the server.
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 808
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Client runs faster than server
Thanks for the reply.
I was naive enough to think that this was already taken care off, ie. that addTimer was a fixed loop. I just did an offset calculation and viola! The numbers are not screwed up.
I was naive enough to think that this was already taken care off, ie. that addTimer was a fixed loop. I just did an offset calculation and viola! The numbers are not screwed up.
- tef
- Posts: 10
- Joined: January 7th, 2011, 3:38 pm
5 posts
• Page 1 of 1