Any performance or other benefit - multiple .blend files?

Is there any performance or other benefit to be had by spiting scenes, or in my case game levels, into their own .blend files to be called externally as needed?

Smaller RAM footprint on start-up, faster load time on start-up, advanced asset mangement during runtime, advanced asset management during development. Those are all common benefits to using a multi blend method. Look up LibLoad for more info on how to achieve it.

Next to what CaptainAndrew said, splitting your file into separate blends makes it easier to modify and extend your program in the future. It’s analagous to the reason programmers don’t put their entire program into a single function - it’s only useful for a really simple or tiny program; the same goes for games.

You both make some excellent points, thank you! I was looking at it from an organizational and performance perspective and it looks like both can be improved in this manner. One question, however, can one still package everything - all the .blends, etc. - together to form a standalone executable?

Looks like the script to call up the .blend looks something like this?

bge.logic.LibLoad(path, 'Scene')

So would the following work? That simple?

bge.logic.LibLoad(\levels\level1.blend, 'Scene')

For the path, use the logic module’s “expandPath” function. “//” means a relative path, so “logic.expandPath(”//levels/level1.blend")" should give you the path you need to push into the LibLoad() function.

No, you can’t package external blend files into a single one. Maybe someone knows something I don’t though, and it’s possible to use LibLoad() to asynchronously load in an internal scene…?

its great for if your going to use something 100’s of times,

so changing the “root .blend” changes any instance that is spawned.

You can create a zip archive that contains the executable and assets. This is why folder structure is important when creating a game. I recommend reading Prof. Monster’s Hints, Guides and Good-To-Knows:.

Something I learned from experience is the best way to use LibLoad is to think of it as adding to your library of objects that you can add to the scene. Originally, I started out using it to load objects directly into the scene, however this is not optimal for various reasons.

To do this, make sure for any blend files you LibLoad, the objects to be added are all on an inactive layer. Generally, I make the first layer empty and put objects on all the other layers. However, what layer they are on doesn’t matter as in the BGE, KX_Scene ostensibly has only one inactive layer and so objects on layer 2,3,4, etc. in the blend file will end up on the same inactive layer of the KX_Scene in the BGE (KX_Scene.objectsInactive).

Once they are LibLoaded, you can just call KX_Scene.addObject(…) to add objects to the active layer (scene). This allows you to cleanly add as many instances of the object as you want. I think they share the same material so if you need different objects with different materials, LibLoad as needed.

And how about the sort of opposite… is there way to copy a scene from one blend file into another blend file? There doesn’t seem to be any ‘copy and paste’ or import sort of option.

Say I have a game level in its own .blend that I want to incorporate into another bigger .blend containing 5 levels (scenes)…

You can link scenes by going to the file menu, selecting Link, going to the target blend file, and linking the entire scene. You won’t be able to edit anything in the level, though, and this isn’t equivalent to LibLoading as this is a single instance, and can’t be loaded asynchronously (while the game is running and doing other things).

I think to LibLoad a different scene, it needs to have a different name than the currently active scene, otherwise all the objects in both the active and inactive layers will be merged into the current scene.

Once it’s loaded, you can just do logic.addScene(…).