How would you approach making your Babylonjs browser game moddable?

I’d greatly appreciate some kind of direction for how to approach the problem. Normally, on regular PC games, you can just download files and put them into the right directory to mod a game, but what if the game is entirely browser-based, and intended to also work on mobile browsers?

I can think of a couple of convoluted solutions, but they don’t seem very accessible for the casual user.

It seems like quite a challenging problem. What would you do?

i am a little confused about the question and what answer exactly you are looking for. Is it about - how do I add assets to my web-based game? If yes there are many different ways you can do that. Assets can be serialized and be a part of your compiled sourcecode - not good for web deployment, but perfectly fine for an offline or mobile game. You can store the assets in a local database (similar to what we are doing with our cache mechanism - we store the blobs in indexeddb and load them when needed).
If you are asking something else (as I am not 100% sure what you mean with " moddable", i will be happy to answer that as well. Of course, only if I have an answer :slight_smile:

Thanks for giving it some thought!

Mods: Creative players can create ‘mods’, which are modifications to the game that alter gameplay. For example, if the game is about civilizations at war, then a mod could be your own civilization with its own graphics, code, etc.

What I intend is that players can modify (make ‘mods’) the game that I’m making to add their own custom features. For games like Skyrim for example, people just download a file and put it into a directory of the game to mod it; but that doesn’t seem to be an option for a browser game (or mobile game intended to be played on the browser).

ohh, sorry. That makes perfect sense :slight_smile:

JavaScript is highly moddable. Adding some form of a “plugin” system for your game, provided a (semi-)public API should be a trivial task. Attaching a new module should be as simple as importing all modules in a specific directory (for example), and executing some form of an init function on them. Or importing them, and running a function on them, that attaches itself to the APIs.
I am sorry it is such an abstracted answer, but there are many ways of achieving this. In Babylon ("vanilla babylon :-)) you can use the observables on every component of the engine to attach to certain events, and do your thing at the right moment. we provide observables to almost every event happening on the engine, so it should be possible to write a plugin that attaches to your scene, just by initializing it with the scene object

2 Likes