Sign in to follow this  
suliman

Realtime basics

Recommended Posts

suliman    1653
Hi
Im trying to make a realtime action game where you control an aircraft, fly and shoot and create units on the ground. So my idea is as following for the networking (up to 6 players)

1. At start of a match all clients sync their gametime so each one has the same.
2. When a player wants to do something, like firing a bullet or turn the airplane a command is sent to server with timestamp (currentTime+200ms). Servers sends this command to each client
3. Each client has a list with cued commands and constantly checks if any of these has hit its execution time: when they do that command is being carried out. This means each client will execute the same command at the same time.

For some questions:
a. What happens if some client recieves a command later for some reason so that command has to be executed after the correct time? In that case that clients world will start to differ from the rests...
b. How do i set a good "delay" (200ms was used as an example above)
c. If timing is important, like in counterstrike, such a delay is not very comfortable for the player. Any other good way to handle realtime action stuff?
d. Is it a good idea to babysit some important events like units being destroyed/ hit by projectiles? (let server alone monitor such events and broadcast to all) To avoid more severe desyncronization?

Thanks a lot (I use raknet and c++ by the way)
Erik

Share this post


Link to post
Share on other sites
Hodgman    51342
[quote name='suliman' timestamp='1307001765' post='4818566']a. What happens if some client recieves a command later for some reason so that command has to be executed after the correct time? In that case that clients world will start to differ from the rests...[/quote]Either -- all players update in "lock step", where if one player gets behind, all other players pause to allow them to catch up (this is common in strategy games - see "[url="http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php"]1500 archers[/url]" for a classic example).
Or, that player would need to be able to rewind their game-state, apply the event in the past, then fast-forward back to the current time (this is common in action games).[quote]b. How do i set a good "delay" (200ms was used as an example above)[/quote]In this model, slightly higher than the expected ping of your players.
[quote]c. If timing is important, like in counterstrike, such a delay is not very comfortable for the player. Any other good way to handle realtime action stuff?[/quote][url="http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking"]Everything you wanted to know about counter-strike's networking[/url].[quote]d. Is it a good idea to babysit some important events like units being destroyed/ hit by projectiles? (let server alone monitor such events and broadcast to all) To avoid more severe desyncronization?[/quote]The client/server paradigm can be very good for preventing cheating -- in this model the server alone would monitor pretty much everything, and broadcast to all.

Share this post


Link to post
Share on other sites
JeffL    153
Another way you can handle laggy information, is instead of insist that all clients start everything at exactly the same time and then increment objects position every frame by their velocity, send a starting position, starting time, and velocity for each object, then the update loop would just multiply the velocity time the current time minus the start time, so even if you get the info on that object late, it will still show up in the correct place when it does show up. The other advantage of moving object this way is that it's framerate independent.

Share this post


Link to post
Share on other sites
hplus0603    11356
[quote name='JeffL' timestamp='1307218106' post='4819505']
The other advantage of moving object this way is that it's framerate independent.
[/quote]

Your simulation frame rate should be independent of your display frame rate anyway.

Share this post


Link to post
Share on other sites
JeffL    153
Yes, but if you send the client info on objects in terms of start position, start time, velocity, and acceleration (or in the case of planetary objects, start position, thing they orbit, and orbit speed), then you don't even need to have the clients use the same simulation rate. At least that's how we do it in our game.

Share this post


Link to post
Share on other sites
JeffL    153
I think it depends on your game. If you were going to be talking about launching missiles, for example, then you could make the missile take half a second or more to "arm" before actually firing, which could soak up a lot of the lag you might encounter. Players would get used to that arming time and time their shots accordingly.

In my game, we don't send a message for each bullet fired, we send messages for "start firing" and "stop firing" including the rate of fire, so while you may perceive some lag for when the firing starts, everything is synced up pretty perfectly after that. I think the key is to figure out exactly how you want your game to play, and then pick the best networking scheme to fit that. The more twitchy your game is, the more involved the networking will have to be, I think.

Share this post


Link to post
Share on other sites
hplus0603    11356
[quote name='JeffL' timestamp='1307413869' post='4820348'] The more twitchy your game is, the more involved the networking will have to be, I think.
[/quote]

The advise "pick networking scheme based on game genre" is very good! However, twitch games don't need to be very involved, networking wise -- but they do tend to limit the number of players that can interact in any one arena. This is why a 128-player FPS server is so rare, for example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this