Members - Reputation: 178
Posted 26 September 2012 - 10:01 PM
So recently I have been thinking about what needs to be sent over a network for games to stay in sync. In regards to say an MMO, but lets scale it down to the basics. In a one-to-many server-client system here is what I assme happens, please correct me if I'm wrong because I'm very interested to see how this is best achieved (for later projects).
The player has direct control over the position and rotation of the character (so walking around, or flying, whatever) using WADS and mouse and instead of sending the control inputs to the server the position and rotation vectors are sent to the server and the server sends them to all other clients that need to see them (so in the same area or instance). I'd assume there would be a check there first to see if the character has been moved by external forces (being hit by a boulder or collided with an object) first or if the character is still alive.
Perhaps the clients computer takes care of the colisions when the server has sent the position of the boulder and then lets the server know that there has been an impact and the boulder and player are now in new positions. Though I'm not sure who would control the boulder (client or server) if this is an object that all players can interact with, possibley the last player or object to interact with it has control of it's position and rotation.
Then there are actions or skills. I'd assume that the input from the player is again translated into a function instead of being sent directly to the server for it to control. (That was hard to understand, I'm awful at my own native language) What I mean is if I cast a fireball which is skill one. If to activeate it I press the number 1, that keypress is not sent to the server but the client sees the button press and then tells the server that fireball is being cast and not skill one is being cast. Then the server lets everyone else know that the player has cast fireball and tells the others what animation needs to be played and to instantiate the projectile using the pos and rotation and velocity they get from the server. With unguided projectiles such as a basic fireball skill would the server give the velocity and then not worry about it or would it update the information every few steps to make sure sync is possible.
With guided objects such as a homing missile, would that also be controlled by the player that fired it, the player it is following or the server? I'd think server, because it has the most up to date information on everything.
I know this is a lot of information and I'll probably be experimenting with it to see what works best for each situation but I'd like a starting point.
Crossbones+ - Reputation: 3040
Posted 27 September 2012 - 12:28 AM
For a 'homing' object you can actually go either way. You could treat it as a sort of delayed-effect spell: notify the clients of the point of origin, time to impact, and intended destination and let the clients manage the particle, then process the actual effect (explosion damage, whatever) once the time is elapsed. On the other hand, if it's the kind of thing where you fire a homing missile at someone and they have a chance at outrunning it or ducking behind cover while it's in flight then the server would need to have an object representing the projectile.
There are ten kinds of people in this world: those who understand binary and those who don't.
Moderators - Reputation: 5723
Posted 27 September 2012 - 11:14 AM
instead of sending the control inputs to the server the position and rotation vectors are sent to the server
This means that the client can cheat by sending whatever position they want. This leads to teleport hacks, speed hacks, etc. If this is not a problem for your game, then that's acceptable, but for most games, where you are at actually matters. Wouldn't want players to warp to the rewards room after the final boss, without first going through the entire dungeon...