Can you make a server based game in BabylonJS?

Can you for example, run the physics engine on the server, and the render engine in the browser? Say you have a powerful server, and you want to run the high computational stuff on that server, and then just run the graphics in the browser, is this possible?

Hey @Tristan_Berry,

Welcome to the forum!

Yep this is possible and there are many ways to do it. Babylon has a null engine which can be run on a server Server Side - Babylon.js Documentation . Or you could use puppeteer to run full chrome on the serverside and even take screenshots if needed Render a Scene and take a screenshot on a remote server - Babylon.js Documentation . Personally, to keep things simpler I would create a nodeJS server and use the socketio library to just send the positions/actions of a character to the server to keep track of the state and handle all the physics/collisions on the client side while doing validation on the server to stop cheaters (I believe this is how https://shellshock.io works).

Hope that helps.

2 Likes

There is no premade solution for babylon I know of. Depending on what Kind of game your building it can be quite easy to do.For round based games, like most board or card games you can just use socket.io and your naive solution probably works. Fast paced games like fps shooters can be tricky. The reasons for that an how to deal with them are exensively explained on yhis site: https://gafferongames.com

I’m currently developing a multiplayer fps shooter with babylon and already did much research on that, so if you have any specific questions, feel free to ask.

Fun fact: Even the Unity guys didn’t get it right the first time. They anounced last year that they are depreceating a good part of their network api and do a complete rewrite.

These may be of interest


2 Likes