dynamic loaing of terrain (scene's) help

been looking all over and it seems like ppl know how to do it except me. like it’s a hidden trade secret. I wan’t to create an open world game through BGE and know that to do so i would want to pull in python’s libload feature to call in parts of the map and also make use of LOD in addition to that. I can’t seem to figure out how to write the python script for what I want (btw i havn’t done python scripting). I also know that each part of the map should be on it’s own blend file to call from the library.
I was hopeing someone could help me, break down, and explain how to load a part of the map when player get’s to a point where the next part of the map should be loaded when walking around in an open world and free up the parts of the world that i am no longer using. A Dynaimic loading of Terrain and objects
I have seen addon’s or scripts that’s suppose to do this but all out of date and don’t work and i don’t understand any of it. I’ve never been good at explaining myself, hope someone can understand me lol.


you need a method to decide what to load and unload,

Plane you touch?

Distance from point?

x,y position?

the trick is, any calculation has to happen all the time or only during x event.


Touch the door, (unload behind you, load in front)

Sdfgeoff made a resource for this, but I think he is still making it friendly for the non python savvy.

LOD every frame gets distance to player using C++

I wish this property was exposed to us, so you could use it to load objects onto a terrain, and change the terrain LOD with the same data.

  1. I see no hill

  2. I am close enough to see the hill but not the soda cans on it

2 . I am close enough to see the can but not the tab of the can


Below are what you will probably need, but I think you will need a skilled mentor.

LibLoad -> import data but freezes engine while doing

AsyncLibLoad->imports data over time

I hear my name, who hath summoned me. Oh, I’ve been dynamically loaded because the player is near. RIght.

BPR has mixed two issues: dynamic loading and Level of Detail (LOD). There are many tutorials and a built-in system for doing Level Of Detail, so I’ll just cover Dynamic Loading.
I’m afraid I don’t have any nice open-world resources handy as, quite frankley, I don’t like open world games, so I’ve never made any. But, I do know how to do it in BGE, and I know plenty of people who do like them, so here goes

There are a few main ‘things to think about’ for dynamic loading, and they are as follows:

  • When do I trigger the loading?
  • What do I load?

The simplest way that I can think oif to solve both problems is to ‘create’ a 2D array, eg:

And on for as big as your ‘open world’ is. Yes, all open worlds do have limits. It you don’t want any, then make it wrap around to the other side.
Now we have to figure out where the player is. If you’ve organized things correctly, you can take the players X co-ordinate, do some math on it, and figure out where he is. eg:

pos = player.worldPosition
xpos = round(pos[0],2)/10
ypos = round(pos[1],2)/10

The example will be if each ‘chunk’ is 10bu square. It it’s bigger, adjust the rounding and math. You want to end up with an integer.
Now the ones we need to load can be figured out by adding and subtracting one, and we can say:
"We need to load the files with co-ordinates:
[xpos-1, ypos-1]
[xpos-1, ypos]
[xpos-1, ypos+1]

nine up in all.

If we have a naming scheme for our blend files that includes the co-ordinates, then we can assemble this set of co-ordinates into a list of blendfile names:

blend_to_load = 'world_chunk_{}_{}'.format(x_coord, y_coord) #x_coord is a number representing where it is in the array
bge.logic.LibLoad(bge.logic.expandPath(blend_to_load, 'Scene', async=True)

So now we’ve loaded the ones we need to, we also have to unload any scenes no longer required. The easiest way is to get a list of currently loaded scenes from liblist and free any not in the list of blends to load. (Actually, you should also do a check earlier so you don’t try to load the same belnd multiple times)

Unfortunately whilst changing windows 8 to windows 7, my laptop decided to format my two linux installs, so I’m still in the process of getting my system back up and running. Hopefully I’ll make a little demo this weekend.

been looking all over and it seems like ppl know how to do it except me. like it’s a hidden trade secret.

It’s because there are many people are interested in IF it’s possible to make an open-world game but not many go and make one. And once you get more acquainted with BGE and game development you just know how to make it. :slight_smile:

Haha, awesome :smiley:

Yeah sdfgeoff’s da boss for explaining all that.

  • When do I trigger the loading?
  • What do I load?

What sdfgeoff’s outlines is exactly the standard solution.

If you want something more visual you can also place empty objects in the center of your “to-be-zones” and do a distance check from player to them, then load the ones that are closer than some distance that works for you. It’s a bit more resource heavy but you could perhaps make the check every 60 ticks and live if your areas are big enough. The plus is you don’t have to use absolute square or equal sized chunks in grid, you could do free layout. You could have the .blend file names in empties name / property so you don’t have to use numbers as your .blend file name or convert the numbers to names for loading etc.

What I suggest is not trying to make a serious game with such system until you are comfortable with python. (You can always try for fun:) )

-Comment Deleted-

You have misunderstood the deal. The fog is not the solution. The engine still needs to process the geometry that is there even though occluded. Indeed they used dynamic loading or draw distance clipping and the fog is added so that the player doesn’t SEE that the game has not loaded (is not drawing) areas far off.

Or, the GTA III style way. Have a texture off in the distance for other areas of your world. Once you get to the other island (or however you’re doing it), have a loading screen as it loads that other area of the world. You can have the other areas of the world in separate blend files, too. To have it work with logic bricks. However, this is just an idea. Experiment with the different ideas and see what works best for you!

Loading screens is not open world game. When people ask for open world game and libload solutions they usually mean no loading screens. And GTA does do dynamic loading like the libload system in addition to loading screens.

although these post’s didn’t give me the solution i wanted (guess i just wanted something to cut and paste lmao). I did however gained a great deal of knowledge sdfgeoff i believe explained very well the procedure, combined with what Kheetor explained (lamens terms) doing an open world is something best left AFTER someone is used to coding python. Because this isn’t something one can just jump into. cuz all that coding sdfgeoff explained makes sence but as far as someone like me goes with no python skills, would be hell completely understanding myself and typing especially when errors occur. I think it would be way more hastle than i think it is worth at a beginners level. i also hafe to take into consideration that in the same code i also hafe to figure out about loading buildings, objects, trees, light ect… although it could all probably be on the same file for the load. I guess this sort of thing isnt a simple code.
My best option should be to continue to learn as much on this subject as i can while learning python from scratch and do as many things with it as I can. I would very much like to see sdfgeoff’s demonstration he talked about.
I hope post’s keep coming to see what else i can learn

i’ve been trying different things. i know i must not be doing things right I’m using 2.7 and hit play but it didn’t load anything but the cube, downloaded 2.6 and 2.61 and still no success. I also tried tried replacing “file prefix” with the path to the world folder. A very simple code is very helpful, helps me generally understand when things happen and why.

I don’t think 2.61 had async libload, so they won’t work at all. 2.69 is the one I developed it on.
I’ll work on the system a bit more this weekend.