Skip to main content
gamedev.net
🔒 Locked

synchronisation problem

Started by Andreas85 3 replies 900+ views
Original Post
Andreas85
Andreas85
Hello,
i got 2 clients, each running on his own, its a simple tetris like game...
if i dont do anything, they are sync...

the only thing that iam sending over the network is the movement of the cursor and the the switching of two stones!

i thought to solve the problem with packages which contains the gameTime.ElapsedGameTime.Ticks and on the other side/client theres a check routine like: if (package.ElapsedGameTime <= this.ElapsedGameTime)

but i have still problems with synchronisation :/
i read the FAQ, so i came on this idea, what iam doing wrong ?

Can somebody give me some sort of ideas / concepts or hints ?

if there are more information needed, just tell me...

sorry for my english,
Andreas
rip-off
rip-off
We need a lot more information.

For example, are you using a reliable or unreliable protocol? If unreliable, how are you compensating for loss in your simulation?

I'm not sure what you are planning on using the gameTime for. What happens if the packet has an old gameTime?

In general, you cannot depend on two clocks being in sync over a network. In particular, a processes tick counter is highly unreliable, what if one peer was started an hour ago and had been waiting for a peer to connect?

Instead, you might use some virtual "frame" counter, initialised to 0 when the connection is established and incremented every logical step. It still depends on what you want to do with such a value.

Have you considered running the simulations in lock-step? That should simplify a lot of things.
Andreas85
Andreas85
Quote:

For example, are you using a reliable or unreliable protocol? If unreliable, how are you compensating for loss in your simulation?


reliable protocol, calling: SendMessage(sendBuffer, NetChannel.ReliableInOrder1);

Quote:

Instead, you might use some virtual "frame" counter, initialised to 0 when the connection is established and incremented every logical step.


that iam doing sorry for wrong explain... :/
its not a good concept ?

Quote:

Have you considered running the simulations in lock-step?

no...
rip-off
rip-off
I can't really help you at all until you describe your current setup more. I could talk about synchronisation in general, but the Forum FAQ would probably be more complete and accurate.

Why not describe, at a resaonbly high level, how your current setup works and how it should keep in sync. You need to tell us what you have tried.


Quote:
Quote:

Have you considered running the simulations in lock-step?

No.

Does that mean "no, I haven't considered" or "after considering, no I won't be doing this".
hplus0603
hplus0603
First, for network sync, you almost always want to be using virtual "ticks" instead of time. For example, for a turn-based game, you can easily have five ticks per second (so, at 60 Hz, 12 frames per tick). Have each game send its commands to the other side at the end of each tick. Have each command actually take effect at the tick two after the sending tick. This makes sure the sides are in sync.

Send a "no commands this tick" command if there are no commands. If you don't receive that packet, there's a network problem, and you should pause the game until the packet shows up.

Tick N:  If hasn't received tick N-2 from all players    Pause the game  else    Run commands queued during tick N-2    Collect user input    Send commands to other player(s)


You'll want to run this as a state machine that you "poke" every frame, because your graphics frame rate will be faster than your network/command tick rate.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.