Sending player position packets to client computers

Started by
3 comments, last by DividedByZero 14 years, 5 months ago
I am working on a point and click 3D multi-player LAN game where there are 4 players in the game. For updating the position of a player character on other computers, I plan to just send the destination position of the mouse click to other computers so that the same character on other computers will perform its own translation calculations to get to that point. To make sure that the character on other computers are generally on the right track, the server will send periodic updates to other computers so that they can check and correct the movements if necessary. Is this method sufficient for its purpose? And generally, how frequent should the periodic updates be sent? (e.g. every 12-15 frames?) Currently, what I do now is to send the position directly to other computers every 5 frames regardless of whether the player is moving or not. The other computers will just translate the player character to the position received. It is simpler but I think it is the reason why the game's frame rate drops when 4 players are playing together.
Advertisement
It sounds sufficient. The rate at which you need to send the updates is proportional to the speed at which units move. As an extreme example, if a unit moves at a rate of 1 pixel per minute, then even 1 update per 10 seconds is more than you need. In theory it's also proportional to the amount of jitter in your network connection and to how often a unit may change direction but I think that's overkill for your purposes. My guess is that 5 times per moving unit per second will be enough if units typically follow straight-line paths.

PS. Consider the cheating implications of sending destination clicks to opponent players.
wouldn't you want to send a packet every time the player moves to a differnt x,y,z pos? Or would you want to send a packet everytime they stop moving an then send a map update also.
If you're doing floating-point simulation, then the player is at a new x,y,z pos each frame.

However, given that your frame rate will vary on different machines, I would suggest setting a send rate. For example, each machine could send an update 5 times per second (every 200 milliseconds). That way, network usage is predictable, and doesn't vary with frame rate.
enum Bool { True, False, FileNotFound };
I also do the same as mentioned above. Although I send even less frequently (1 second intervals) as it doesn't worry me too much if things dont look identical on each PC as, generally, the users would never know the difference.

It all depends on how you want your program to operate.

This topic is closed to new replies.

Advertisement