Advertisement

Net Game Design

Started by June 16, 2004 04:05 AM
9 comments, last by FireNet 20 years, 8 months ago
Can anyone tell me how to synchronize all the player in the game?(My game is based on Lobby and there are 2-8 players in one room)
By sending authoritative data about each player to each player every so often.
enum Bool { True, False, FileNotFound };
Advertisement
The time when the msg reaches clients is different, so it may work incorrectly.
You will have to live with it.Actally the lag will not be more than a few milisecs if you send all the req info in one shot to all the clients in the lobby.

Another alternative is allowing the clients to request that info.

Maybe you can give a little more details as to how you server works?
______________________________________________________________________________________________________
[AirBash.com]
My game is something like a 2-D shoot game,and the clients just send the moving command such as go right,go up and so on.The server processes almost all the details and there is no host except my server.When one shoots another,the server should keep track of the bullet and send the coordinate to the clients.Thus the clients should have the same coordinate of bullet in screens.I know this is inefficient but this can diminish cheat.
So how to synchronize all the player in the game?
i'm maybe not the right one to answer this because i'm not very experienced with multiplayer but here are my two cents anyway.
1. I believe perfect synchronization doesn't exist! The aim is to synchronize the most possible. And it's also utopian to think there could be some "synchronize" method to do that magic.
2. General comment: avoid sending uneccessary data.
3. go right,go up and so on => no!!! Like this there will always be tiny differences that add up every time which can result on big differences! Instead, you should send the exact state (x,y) (and maybe also speed if needed to interpolate on other clients). That's much safer.
4. Perfect synchronisation is utopic as said before. But people can live with it, usually people don't even know if they're unsynchronized! The thing that matters is that they "feel" what they see! If on my PC and i avoided the missile, i'll be frustrated if the server (or another one) computed i've been shoot because the state of the game was a bit different there.
=> send what happen to you (your ship, your character...) and don't let it be computed on the server. (And there's usually also less data amount when doing that). Every one send what's happening to him only and recieves what's happening to all the others in the same time.
5. If you know you'll have to deal with slow connections and the delay between sent and recieved. And that you have predictible behaviors based on time in your game. Then then you could take advantage of it. Let's illustrate it with a short example: a bullet is shot:
Once you know where the bullet was shot and it's velocity, you can compute it's exact position at every moment in time. So, just send pos and speed infos once and when you recieve them, retrieve the message delay to have the right function of time for the bullet's pos. It's a way to synchronize and save sent data amount.

well, hope it helps.
cheers.
Advertisement
Ok Let me deal with that bullet.

When a person fires a bullet it move in a direction with a specified speed (bases on time).So here you can just send the starting location of the bullet to all the clients or even just who fire the bullet.The clients can then show this on screen and the server can do the collision detect for the bullet hitting a target and update the clients on that.

Hold a sec,do you already have a server and having probs ???
______________________________________________________________________________________________________
[AirBash.com]
What do you mean? Sorry, i didn't fully understand what you wanna say/ask. I just said that you can simply compute the pos of the bullet with (for example):
x = x0 + vx*t
y = y0 + vy*t
where t = currentTime()-startTime. And where startTime is the time when you recieved the message minus it's delay.
That's all.

But there is something else that is annoying me: it's this usual server-client vision where the server computes all and the clients are just "passive" recievers. It's maybe personnal but i don't like it. I prefer the way where every "player" is equal, there is of course a host where people join to but then every one is both server and client together. Meaning they compute only what's happening to them and send it, and don't compute what affects others because they will do it!
So, for me, collision detection should be done on client side. Your ship shoot the bullet and that's all, don't bother to know if it hits someone, you'll recieve a message if a ship has been hit!

Collision Detection on the clients side may cause major sync probs.It's usualy to keep all the physiscs on the server but I do agree keeping the clients as passive recievers is prob waste.They can share some of the work too you know.

misterX,You did say something about everyone being eqaul,well if you want it from the play point of view the server has to rule or there will be major sync problems and cheating too.
P2P network gaming might be possible though.
______________________________________________________________________________________________________
[AirBash.com]
So can you tell me what kind of work can be shared with the clients?Thank you in advance.

This topic is closed to new replies.

Advertisement