How to keep a consistent list of levels

Godot Version

Godot 4.2


Hi ! I have finished creating the level loader for my project but I am kinda confused about how could I keep a consistent list of my levels.

I am currently using a state machine to switch between levels, and a parent level-loader class that tracks dynamically every “level” state I add to it and store them in an exported dictionary. Then I pair the according level PackedScene file path to each “level” key in the inspector.

The problem is : I don’t know how to access this list from unrelated classes (let’s say a door that would lead to one of the levels and display a ui screen nearby displaying the level name for example). My goal would be to have a dropdown dynamic list in the inspector for that door to choose which level it leads to and a relevant description that could be easily edited by writers.

I am almost certain I could use a resource instead of a node class to store these informations, but how to keep that dynamic enough so that every time I add a new level to the state machine, the resource updates itself accordingly ?

My constraint is to avoid duplicating any data across the game.

I am thinking to switch my primary source of data from the states to a simple custom “level” resource that could be accessed by all classes in the game, whenever need and that I could painlessly expand afterwards. Any advice on that matter would still be highly appreciated ! (I really suck at using resources and i am afraid to do so)

I’ve already made a post on a similar topic here. maybe it will be inspiring

Great ! I think I’ll go with a generic “GameLevel” resource, but your approach seems pretty consistent to populate levels. I am a bit cautious with arbitrary naming conventions because we’ll be several people to work on the game (mostly non-devs) and I guess it could lead to bug pretty quickly if someone doesn’t respect the convention.

1 Like

Yes, it’s a matter of approach, but you can also in this case make a table where the names will be assigned and they will just be displayed at the trigger, so it doesn’t have to be stored as I do.

My point was to create a LevelTrigger through which I will access other levels, and I didn’t want to make a table :smiley: