Jump to content

Multiplayer game - How much data should be sent to the client and how big?


Threedy
 Share

Recommended Posts

I have am running a 3D multiplayer physics game where I currently send the input (4 keys, position: x,y,z and velocity x,y) to the clients (8 clients in total) 30 times a second.
 

Is this considered to be a bit too much? Also, I assume changing (1) to (2) would decrease the size of data that is sent?
 

(1) var keys = {l:true, r:true, u:true, d:true};

(2) var keys = {l:1, r:t1, u:1, d:1};

Link to comment
Share on other sites

  • 2 weeks later...

Haha thanks for the comment guys. I managed to bump it down to 10 ticks :P 

Anyway, the current bottleneck seems to be the physics engine itself (CannonJS).When I add 400 boxes, only floating in the air, I notice quite a bit of lag (only for 1 player in 1 game). I'm pretty bummed out. Perhaps it was a bit too ambitious, a 3D realtime multiplayer physics browser game.

Link to comment
Share on other sites

On 4/4/2016 at 1:30 PM, Threedy said:

Haha thanks for the comment guys. I managed to bump it down to 10 ticks :P 

Anyway, the current bottleneck seems to be the physics engine itself (CannonJS).When I add 400 boxes, only floating in the air, I notice quite a bit of lag (only for 1 player in 1 game). I'm pretty bummed out. Perhaps it was a bit too ambitious, a 3D realtime multiplayer physics browser game.

Hmm. Do you have an example of this? You can pm your link if you don't want it public.

Regarding the physics, if 400 is too much do a dynamic range visibility check. For example, on my game if there are 100 mobs loaded in the map, only show the ones that are visible within 700 pixels (screen's width/height). This helps tremendously. You could also setup web workers, but you would then need to send data over and back to update, so that might not be beneficial. Just do some trial and error stuff. 

400 boxes does seem like a lot, but how many should be in view on the player's screen?

Link to comment
Share on other sites

4 hours ago, Fricken Hamster said:

Another way to optimize data size is to send binary. Then you can take all the booleans and pack them in groups of 8 to make a uint8 using bitwise operations.

I think BSON would help with that too if they are doing a JSON-like transmission.  I have always been looking for benchmarks comparing Binary Websockets to Text.  

Link to comment
Share on other sites

  • 2 months later...
On 4/5/2016 at 8:32 AM, michaelcalkins said:

I'm doing something similar in the browser with a 2d platformer and websockets.  

You're sending a perfect amount of data.  Too much data is when you send unnecessarily large datasets multiple times per second.  Just send the absolute minimum.

I agree, if you're using WebSockets, large data packets won't normally cause lag. It's when you send too many individual messages that servers lag.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...