Advertisement Jump to content


This topic is now archived and is closed to further replies.


Synchronizing computers in a network game

This topic is 6776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to synchronize computers in a network game so that each computer can individually process the movement of, say a missile. For example, if one player launches a missile it will collide with a wall on their computer at the same time that it does on the other person''s computer, but both computers individually processed the movement of the missile. Does that make sense? How can you synchronize the computers? Maybe keep the frame rate the same on both? Make the faster computer go only as fast as the slower computer? Theories are good, but I''d really appreciate actual code examples. Thanks, Alex

Share this post

Link to post
Share on other sites
Yep, you''ve had a very good idea.... Luckily others have already baked it for you.

Read about 2-3 months down the list for a post by drone. He links to the source you could use.

The idea is simple, and independant of framerate. It all come doen to timeslices.

All you need to do is say x happened at y time then send that message to everyone. As each person recieved the message they integrate that event at the appropriate time in the past and display how the world would look should that event have happened.

It''s a VERY efficient method as all you need send is "user5 fired weapon7". It''s a little more complicated at each client end as you need to be able to have the ability to integrate things that happened say 500ms ago and forward calculate how things have changed since then.

Look up all posts by Drone about 3 months ago and any post that contains the word "Lockstep"

Drone also lists a forum on an ezboard where specific question can be asked and more info obtained.

Drone has offered his code openly, I''m still working on my code which is a little more difficult to understand as I use UDP and have to do more to make it work.

The moral of the story it, this works wonders but you have to make sure that EVERY person gets every event. This method doesn''t handle packetloss.

Good luck, it''s a good method which whips quakes ass when it comes to lag and efficiency...


Share this post

Link to post
Share on other sites
Good question. There are 2 possible approaches to solving the problem.

The first method is described by gimp: each host runs his copy of the simulation in lock step with the others. You tell everyone the exact time the missle was launched and it''s trajectory, and everyone performs collision checks every frame. As long as the hosts are perfectly in synch, then they will all see it hit the wall or not.

The biggest drawback of this method is that the networking is limited to the speed of the slowest host (since he must handle every network message before anyone else can proceed). This method may work for turn-based or RTS games, but probably not so well for action games.

The second method is to divide data into 2 categories: status updates and state changes. The first kind of data is just basic position and direction information for the player''s object (his character or ship), which can be sent quickly and unreliably -- giving pretty smooth motion at the cost of a little accuracy. It also includes other status information like current score, visible damage, or whatever.

The second kind of data, state changes, are actually negotiated with a "simulation authority". The simulation on this host has the final say -- he manages the creation, destruction, capture, and collision of objects in the world. He tracks the locations of everything, so when you have a potential collision, he confirms it. When 2 players aim for the same resource, he checks the timestamps of the requests, and picks the first one.

Finally, to put a spin on it, the simulation authority doesn''t have to be a single computer. You can divide the responsibility among several hosts (eg, each player controls his own zone), or pass the authority from host to host in order (eg, a turn-based game).

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!