Do you use multiple scenes?

So the way I have my game structured currently, I use one scene for the menu, and another scene for the game itself. When starting the game from the menu, the menu scene is destroyed and the game scene is created. When changing levels, the current game scene is destroyed and a new one is created. And when returning to the menu, the game scene is destroyed and the menu scene is recreated.

I’m starting to think this is not the best way to go about this as it requires loading all the resources over and over again. And I’m not using babylon files so I can’t cache them in the IndexedDB.

How does everyone else structure their project? I’m thinking that maybe I should just have one scene for the menu and another for the game that I reuse instead of recreating them over and over again? Alternatively I could create a single scene that is used for everything, and throw everything not being used into AssetContainers.

Any thoughts?

Hi @jeff2365 and welcome to the forum. This PG (playground) shows scene switching .

It is from Use Multiple Scenes - Babylon.js Documentation where it is worth reading about differences between doing in in your own projects and in a playground.

Thanks John, I do understand how to use multiple scenes, but I’m more interested to hear about what sort of patterns people like to use in their own projects.

Well I’ve converted my project so that the menus and gameplay all share a single scene.

This does add a little complexity in some places because I have to unbind and rebind observers or clean up meshes, though it can be abstracted away.

But some other things become simpler because I can load everything at once and load it only once, and know that it is already loaded when I need it.

I’m still curious what other people do.