🎉 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!

Measuring lag time precisely

Started by
11 comments, last by ByteMe95 23 years, 8 months ago
I dont know what you meant by "dont send the bullet", but all isend when a bullet is fired is the bullets x, y pos and its x, y velocity and then i call createbullet. Then the local machine takes it from there.

ByteMe95::~ByteMe95()
Cerebrum Software
ByteMe95::~ByteMe95()My S(h)ite
Advertisement
I''m in a similar position: I''m writing a 2-player Asteroids clone which I''m trying to network. See my homepage for its latest (single-player) incarnation.

As I see it, you don''t need to exactly synchronize both computers. Just halve the average round-trip ping time to make sure both games start at roughly the same time, then store the local start time on each computer. When sending information packets, include the time since the game started. Then, when you receive a "create missile" packet, say, actually create the missile at the point it would be (taking into consideration its velocity) if it were created on your own end at the same time since the game started.

If one computer is actually running a few ms behind the other, it will get slightly better response times.

For each missile, I''ve given the originator control over collisions. Therefore, neither player has an advantage. If I had made one computer the server, the player on that end would have a huge advantage. The only tricky bit is with missile-player and player-player collisions. In these cases, both ends confirm that the same thing''s happened on the other end before proceeding. Since there''s a natural break when a life is lost, this isn''t much of a problem.

Everything has a velocity, but only the players'' ships have any acceleration. Every time an object is created (missiles and broken asteroids) a packet is sent. When the players thrust, a packet is sent with their position, updated velocity, and the time.

I do make sure that packets get through (with ACKs), but for thrust packets, the new packet overrides any old (unacknowledged) packet containing a previous thrust.

Before the game starts, and at the start of a new level, the computers synchronize (roughly) and agree on the position of the asteroids before starting.

Once I''ve finished implementing all of the above (nothing is set in stone yet), I''ll put a 2-player version on my homepage.

Dave
see my thread in this forum about time syncronization

send a packet from the slave to master with its clocktick in it, the master returns the packet with the original clocktick and its (the masters) clock tick, on echo of the time packet you can calculate the lag (ass-ume equal transit in both directions) and then you can calculate the clocktick offset from one computer to the other. You can then send updates in this absolute time reference.

SendBullet(time, x,y, dx, dy, ddx, ddy, dddx, dddy); time syncronized cubic dead-reckoning. ''cource t, x, y dx, dy is probably good enough for a bullet...
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement