Jump to content

Server side animation in babylon


Nikos123
 Share

Recommended Posts

Following on from this comment about how to animate agar server-side, I was wondering if anyone had attempted to use Babylon in such a way? I ask because this would seem useful in future versions of my Babylon RTS game.

https://github.com/huytd/agar.io-clone/issues/288#issuecomment-275858908

Quote

Here is the common way used in most multiplayer game:

Server has an update loop (60FPS), where it computes the authoritative physics of all the entities.
Then, there is a broadcast loop to send all states (but optimally, only states that have changed should be sent). Ideally, a broadcast loop at 60FPS would be nice, but that's too much for the bandwidth. A lot of games (like Overwatch) put it at 20FPS.

So the client receives states at ~20FPS. The direct rendering of that would be not smooth.
One solution would be to interpolate: for each entity to interpolate, buffer all the states received in an array of updates (with limited size). Server should have sent the timestamp along the state, so the client can interpolate. The last timestamp received will be stored as the serverTime, in the client. As the client needs at least 2 updates to interpolate, he should define an interpolationTime (i.e. 100ms). So the client will render 100ms in the past: renderTime = serverTime - 100.

Then, there is the rendering loop (client slide, ~60FPS): the client should update the states here as he has arrays of updates(serverTime, state). To update one state before rendering it in the current frame, he loops over the updates and find the 2 ones such that: updates.serverTime < renderTime < updates[i+1].serverTime. Do linear interpolation with renderTime as the factor, and update the state.

Client-side prediction is more difficult as the server and the client are not synchronized. Very difficult for entities that use timestamp (in fact, idk if it is possible).

 
 

 

Link to comment
Share on other sites

I know that Three.js can run server-side using Node.js.

So can Cannon.js, making all physics calculations authoritative on your Node.js server, while using Cannon.js on the client as well, to do prediction.

I haven't tried Oimo.js, so I have no idea whether that would work as well.

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