Threedy Posted March 20, 2016 Share Posted March 20, 2016 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}; Quote Link to comment Share on other sites More sharing options...
rgk Posted April 2, 2016 Share Posted April 2, 2016 I wouldn't worry about it much but yeah you are sending less data with 1 then true. Have you noticed any lag so far? Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 2, 2016 Share Posted April 2, 2016 30 times a second? Client prediction is needed here, that's insane man. Quote Link to comment Share on other sites More sharing options...
Threedy Posted April 4, 2016 Author Share Posted April 4, 2016 Haha thanks for the comment guys. I managed to bump it down to 10 ticks 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. Quote Link to comment Share on other sites More sharing options...
michaelcalkins Posted April 5, 2016 Share Posted April 5, 2016 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. Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 6, 2016 Share Posted April 6, 2016 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 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? michaelcalkins 1 Quote Link to comment Share on other sites More sharing options...
Fricken Hamster Posted April 7, 2016 Share Posted April 7, 2016 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. Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted April 7, 2016 Share Posted April 7, 2016 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. Quote Link to comment Share on other sites More sharing options...
kevdude Posted June 11, 2016 Share Posted June 11, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.