Jump to content

Streamlining multiplayer scene updates


ozRocker
 Share

Recommended Posts

I'm using Babylon.js for my multiplayer games, but this question can apply to any type of multiplayer game.  I cannot find any answers on the net though so I'm just asking all the forums.

Does anyone know the best way to streamline server updates to the clients in a multiplayer scene?  For example, if you have a massive world with 1000 avatars walking around, laying down landmines, etc.. you wouldn't want the movement of every avatar broadcast to all the clients.  That would be a massive load on the server and clients.  I'm assuming you would only transmit avatar updates to clients that can see that avatar, or is a certain distance from that avatar.  This would also apply to dynamic objects in the scene and collision detection (assuming collision is handled by the server).  Anyone know of any articles/tutorials on the net that explains how this is done?

One method I thought of was to cycle through every client that's connected to see if they are in the vicinity.  But that could take too long.  Then I thought of splitting the world up into a grid so then I can narrow doing all the checks to just clients within the neighbouring grid squares.

Link to comment
Share on other sites

I have done a fair amount of http client / server, though none of it for gaming.  Adding the position and direction of the clients camera with every http put might be a good idea.

Your server could then update its in memory DB of objects it is tracking, then use your camera's location / direction to see what to send back.

The other way that makes sense is to include the SERVERS timestamp when things are sent down.  The client also returns the stamp of the last call in its next call.  If the server time is in each record of the DB, I would then just cull the things the client already knows.

I do not know which would be faster, but think the timestamp would probably be the one.  You could also combine them, BUT you would need to indicate when the camera has move since last call.  Or only sending the camera status implies to return based on proximity, else based on time.

I know not of any books, but think doing "whatever" on the SERVER is better than cycling on the client.  It should also be much easier to experiment & change methods, if the process was on the server.

Link to comment
Share on other sites

thanks for the tips @JCPalmer I don't really understand how the timestamp method works.  If one player has been stationary for a minute and another player runs in front, or drops a box in front of them that should also update the stationary player's view.  Maybe I misunderstood.

I'm thinking of scalability.  The server could get really bogged down if with every frame of movement from every player and every object, it needs to do a comparison to every other player to see if its within view.  There must be some kind of standard process that games like Warcraft would use to solve this problem.

Link to comment
Share on other sites

One massive life saver is not to give exact location, but direction or target position etc... this won't help with server lag, but will help with client... so if the network hiccups, then the character will still flow in the correct direction.
Aka this player is going towards 300,20,21 or something - it all depends on what type of game you're making, of course.


Also, be sure never to update the position if you don't need to - if the client already knows where a character is, and that character hasn't moved, no need to push any updates!
And yus timestamps are great too.
(I don't know too much about this, but have researched and a made a mini multiplayer game thing)

Good luck my friend!

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...