#Best loading methods?

5 messages · Page 1 of 1 (latest)

sturdy fractal
#

I'm currently making an open world 2D game that uses TileMaps with a scene collection tileset. Each scene just contains a label and collision body, so they're not too complex (but it does load in a lot at once)

Originally I was going to have the entire game be one big TileMap, but I was afraid of that hindering performance on lower end machines, so I changed it.

I now have it so that when you reach a certain point in the map it'll load the next map scene, instantiate that map, and then add it as a child to the main node before doing queue_free on the previous map scene. The idea is for the loading to be seamless.

The issue is that once the code hits add_child it has a pretty noticeable and significant stutter as the game loads in the next map's scene. I was wondering if there's a way to prevent the engine from freezing the game to load in a child scene, or if there's another way I should go about loading in and out maps.

The other idea I had was load all of the maps in at once, then change their visibility when traveling from one section to another. I don't know how much this would realistically help with optimization, though.

Any ideas?

#

And for the record this game doesn't use any particles or shaders, the only visual elements are labels

rancid gust
#

Are you using load() when the transiton happens?

Im not 100% sure too, but i'm thinking if preload() can help.
See: https://www.dragonflydb.io/faq/godot-when-to-use-preload

I imagine having an Autoload Node, maybe called MapLoader.
With a list of var sample_map: MapSceneClass = preload(MapScenePath)

Then when you need the MapScene to instantiate, you call
var MapScene := MapLoader.sample_map.instantiate()

sturdy fractal
#

That doesn't help, since the lag happens on add_child

#

The lag comes not from loading the scene, but from the TileMap in the scene loading all of its scenes