Jump to content
  • Advertisement

Archived

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

executor

Synchronizing players

This topic is 6764 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

I have problems synchronizing two players with DirectPlay. The problem is that one computer is faster than the other and it''s units are moving faster. The efect is that two units (one from each player) that should be moving at the same speed are moving at different speeds. One computer has 40 fps and the other has 20 fps. With each frame the unit is moved two pixels. This way the two units are moving at different speeds. How do I make them move at the same speed? (It''s a RTS game with peer-to-peer DirectPlay multiplayer)

Share this post


Link to post
Share on other sites
Advertisement
I can think of two solutions. The first (but not the best) is to limit the framerate to the lowest system. What you might want to do instead is limit your framerate to something high, say 60 fps. At each frame you need to determine how much time has passed since the last frame and then move units accordingly. If some units are moving at 1 pixel/frame at 40fps then you might have to create more detailed position information based on some unit rather than pixels, like 4 units = 1 pixel. Tell me how it works out, I’m looking at creating a multiplayer RTS this summer and would be interested to know what other issues come up.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Seperate the update of the units from the frame rate. Synchronize both clients to a timmer, and use that timmer inforamtion + data to extrapalate position of units. That''s the way i do it. Good luck.

-ddn

Share this post


Link to post
Share on other sites
I''ve seen a lot of games (Yes commercial ones) use time for unit posititioning rather than frams. So the rendering of the screen is a totally different part of the program than the updating of the units. So the frame rate doesn''t matter. So when you update your units you calculate the time it''s been between the last update and now and then use your speed (30 pixels per second or something) and calculate the distance to move it.
Try looking at Microsofts Age of Empires. It works like this. We networked a game from a P133 w/out MMX w/ a 2Mb generic graphics card to a PIII 533Mhz w/ a Voodoo 3 3000 and 128MB of ram. The frame rates were like 12-15fps vs. 60fps. But you could see the unit moving further an the slower computer per frame. The graphics just look a bit choppy on old systems.
Hope that helps!
- Ben

P.S. According to a recent thread on Task and Thread prioities in windows. Many of these games we talk about hav multiple threads running. Maybe they''ve got a thread syncing and moving all the units and thread that paints everything?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!