Nikos123 Posted January 29, 2017 Share Posted January 29, 2017 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). Quote Link to comment Share on other sites More sharing options...
Raggar Posted January 29, 2017 Share Posted January 29, 2017 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. Quote Link to comment Share on other sites More sharing options...
Nikos123 Posted January 30, 2017 Author Share Posted January 30, 2017 Thanks, I imagine this would be a pretty big task if Babylon doesn't already do it. Quote Link to comment Share on other sites More sharing options...
Nikos123 Posted February 5, 2017 Author Share Posted February 5, 2017 Anyone know if Babylon plans to add anything like this? Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted February 5, 2017 Share Posted February 5, 2017 @Nikos123 Check this out; http://www.gabrielgambetta.com/fpm_live.html // enable Prediction & Reconciliation, use left & right arrow keys. Quote Link to comment Share on other sites More sharing options...
Nikos123 Posted February 5, 2017 Author Share Posted February 5, 2017 Wow nice, thanks for that, will study and get back to you! Quote Link to comment Share on other sites More sharing options...
Nikos123 Posted February 12, 2017 Author Share Posted February 12, 2017 I'm just gonna start from this tutorial http://buildnewgames.com/real-time-multiplayer/ @aWeirdo @Ragger I liked the animations that Babylon provides with the easing but I guess I will have to work that out on the server now. I don't know what the issues with these forums are, I never get email notifications. Quote Link to comment Share on other sites More sharing options...
Nikos123 Posted February 12, 2017 Author Share Posted February 12, 2017 I've discovered this: https://github.com/OpherV/Incheon I've asked some questions: https://github.com/OpherV/Incheon/issues what do you think? 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.