Is it possible to make a level seamlessly load into another?

Like the title says, is it possible to make a level file of any kind seamlessly load into another or phase into it? I’ve seen this in open-world games, so I suppose its doable within UPBGE 0.3+. I just don’t know how.

However, open-world levels are kind of risky in UPBGE, as not only as they are slow, but also can crash UPBGE due to the amount of assets needed to load, which often exceeds the app’s memory requirements.

yes, it is possible - but you need to either generate it in parts, or generate it with geonodes - again in parts, for this your map sections must either be divided into parts, which will ensure smooth loading, or you must perform tessellation through geonodes so that when moving the camera, the detail of the landscape next to it is unacceptably high and decemation occurs at a distance, regarding your question about objects for the landscape - you can make a texture atlas for them and, for example, bake a common texture for 5 objects, so do all large studios, or generate something from objects with geonodes - there are lessons on this topic about generating trees and vegetation - this will give you variability with a small number of objects in collections - but here, the same compromise is needed - either you have a detailed level, but it is small - limited by corridors or landscape, or you have an open world, but then you need to do most of the content in it procedurally, or optimize it at the manufacturing stage - the choice is yours

Use a empty / distance from the empty to strip faces off meshes to “fill” using geonodes, have data pre_encoded in the ‘hint meshes’ to and have the hint meshes in invisible / no collision.

For interactive elements use pooling

What is “pooling”?

Hmm… how can I implement an object pooling system in Python? Can you provide an example on how I could create this? I don’t really know how to add a pooling system. Maybe it has to be done via globalDict?

I reckon pooling can be done in Python, but I don’t know how to do it.

I think the object pool is like Library in Game engine.
Still BGE can’t do it smoothly even with asyncronize, some old game engine has done it in the old days such as GTA/AC1 etc.
Even today they manage to implement the code of the engine to works on low spec hardware such as Botw in intendo switch and mobile games that using large maps.
This is merveolus engineering/coding in game design and, its not easy to make that specially using opensource software :expressionless:

we have a set number of items - on startup we add these items to a list
this is ‘intializing’ the pool

Ob_list = []
for obj in own.scene.objects:
    if 'some_tag' in obj:
        Ob_list.append(obj)

we need a way to store where each object will be in the scene that needs filled,
I typically use 1 triangle = 1 object and use ‘instance on faces’ to visualize it

startup we cycle through these faces and add their center to a kdtree (we can use p1-p2 and normal to define a rotation also)

the kdtree will then tell you points in a radius from the player that need filled

   kd = mathutils.kdtree.KDTree(len(blenderObject.data.polygons))
   for face in own.scene.objects['pool_targets'].blenderObject.data.polygons:
       kd.insert( face.center, face.index)
   kd.balance()
   own['kd_tree']=kd
   own['filled']=[]

this is used to fill and to free assets to use them again

for point in own['kd_tree'].find_range(point, radius):
    if near[2] < min_distance:
         if point[1] not in own['filled']:
             own['filled'][point[1]] = pool.pop(0)
    elif point[2] > max_distance:
         pool.append(own['filled'][point[1]])
         del own['filled'][point[1]]

that is how this all works

try to simply use the replace mesh stuff , should be enough

That is Interesting, coincidently I was planned to figure it out on how to manage replace mesh on my Landscape mesh which is quicker rather than adding objects, but still has no clues how to do it properly.
Any way my project always to use 50% of Cpu because some good game still able to play it properly yet some are lagging.

its easy, lets say that on your map you want 1000 trees (or any wild life object) that you want around at the same time. Just replace meshes in a pool-in / pool-out based on distance < 100 meters

something like this

objs = [obj for Vector(( obj.worldPosition - player.worldPosition)).length < 100 ]
new_objs = list(set(objs).difference(olds))     ###  those who came into the 
old_objs =  list(set(olds).difference(objs))
for obj in new_objs  :  replaceMesh( " a good looking mesh" )
for obj in old_objs  :  replaceMesh( " a single 1 vertex mesh" )
old = objs

docs.blender.org/api/2.79b/bge.types.KX_GameObject.html?highlight=replacemesh#bge.types.KX_GameObject.replaceMesh

be aware, this is replacing a mesh by another, not an object by another !

image

So basically, you have 1000 trees /objects on your map, you will switch for each of them their mesh whether they entered the 100m or leaved it . Ofc, you can use for many trees the same mesh ! So it will speed up soo much your game comparing if u just gave an unique mesh for the 1000 trees on your map

Sorry my explanation is not quite in details.
I’m not looking on how to do it, In UPBGE 3+ they have added new rendering system to the evee ingame queu such as Dupli-mesh and particles, which is sacrificing Ram.

Any way, Im not looking for Trees either but the lands and its not about LOD’s as well.
So My landscape is so much physics that include for the trees, in my experiences if the file more than 15mb per cells including trees and grasses, it will consume the CPU in half second no mater how good the hardware is because i still use old BGE, just for experimenting on how much the game design is the best, like old games :grinning:

trees is just an example, you can use any object to replace it’s mesh … buildings, ground, characters, trees, plants … you keep the same objects, but you fake multitude by replacing their mesh (randomly or not)

How do I set up the near thing? I used the code, it just errors with if near[2] < min_distance: TypeError: 'float' object is not subscriptable

And how to use point and radius? The near and max_distance and min_distance all seem to expect a number. I write in a number, it says integer or float isn’t supported, which confuses me as integers and floats are numbers in their sense, so what’s going on?

I never use near, but rather getDistanceTo() in python.

import bge

scene = bge.logic.getCurrentScene()
# the object the sensor is connected to
owner = bge.logic.getCurrentController().owner
# the other object you want to get the distance to
Player = scene.objects['Player']
Dist = owner.getDistanceTo(Player)

print(Dist) # distance will show on console

if Dist >= 10:
    owner.setVisible(False)
else:
    owner.setVisible(True) 
    #    owner.endObject()

My Landscape is big, if you experiencing the Terain Design, it would be so tricky.
If the cell is too small there is too much processing in short timing.
If the cell is too big there is too much cpu to calculate the Physics.
Building, Trees, clutter is small objects and mostly has low poly collision.

1 Like

Is this why when I push P, a small memory leak occurs? Cause this can cause UPBGE 0.3 to beach ball on macOS. 2.79 has done it to me many, many times.

Memory leakage occurs depending on how heavily loaded your scene is - which objects are used and what logic is used to generate the landscape and initialize your game at the beginning - in UPBGE 3.0 and higher, object materials are compiled, this is undoubtedly a plus for the start, since they are not calculated later at the start of the game, but if the scene contains a large map immediately it your disadvantage is that you have to hide it and add regions around the player in parts around the player - UPBGE supports offset modifiers and simple texture replacement via bpy, so you can keep one piece of the landscape in the collection and generate the terrain you need from it - object placement also consumes memory if many different objects and placement solutions are added at once there can be a lot of objects, too - I usually use adding one object per generated terrain where biomes are calculated, I did not find a way to add physics to instances, otherwise I would use a rayCast geometry node and a sphere that I move depending on the distance to the camera on a one-time basis - then the scenograph is not overloaded and an acceptable level of frames per second is maintained

Yeah thats depend on the “Main Scene” design it self, one factor is the Itemization UI.
In classic game, Inventory is somehow the most processing things in the game.
So most of them is using pause/suspend trick on changing the UI between main scene and UI scene.
Many has this example when looting on items the main scence is paused during the transfer of the items, which means at the same time Inventory UI is open/unpaused.

This is just classic tricks, not just for Inventory items, but others such as skills/perks and some are used for NPC dialogue as well.
Sadly my game already have Survival concept, so realtime looting is necessary, so I just make my self problems :expressionless:

@BluePrintRandom, how do I define Near and max/min distance? I tried to define the near value, but it says it is not subscriptable.

When I try to do it another way, it says that kdtree expects a number, not float or int (invalid co argument). I’m having real trouble with the near thing, as it refuses to work.