Best practices for managing and tracking resources throughout a game

Godot Version

4.6

Question

Sorry if this is already answered - I searched and was not able to find something close to what I am asking about.

What are the best practices for managing resources throughout a game?
I’m interested in the mechanics more than gameplay at this point, but I’ll take any advice.
I’ve broken my question into a few separate areas:

Basic Scenario:
Let’s say I have a single player game, with 10 levels.
Each level has resources like pickups, treasure, tools, etc.
When a player picks up a resource, it will disappear from the level.
When they save the game, the current resource status is also saved, and reloaded when they restart.
This would be tracked using an array.
All basic concepts, but many ways to implement.

Initial resources setup:
When setting up the game, I could do several things to place and track the resources:

  • I could manually place each resource node and manually enter the item/position into a default array.
  • I could manually place each resource node, and in code, when the game first starts, read each node and fill an array.

Either way, I would then use that array (or better yet, a duplicate) to track the resources during game play, saving, etc. An array of dictionaries would give me the ability to track metadata for each resource (used/unused, etc.)

I lean towards the second method so I can visually place the items at design time, move them at will, and never have to manually mess with the resource array.
Plus, if I use a duplicate array, I could always refer to the ‘default’ resource map.
Is there a better way?

Managing the array:
When a resource is picked up, is it better to set the corresponding array item to null, or just change a flag on the item indicating it’s been used?
Is there a better way to do this?

Inventory:
I’ve seen some inventories that manage the resources directly, but it seems reasonable to me to use the array to add/remove resources, and somehow link the array to the inventory.
What is the better/common way to do this?

If there’s a guide somewhere that addresses these basics, I’d really like to read it.

For the second method, I imagine it could be easier if you want to do things like respawn some resources if certain conditions are met since you’re just flipping a switch and you can run through the arrays or dictionaries to do the conditions themselves.

There is no single or one size fits all solution, like pretty much anything in development (game, physical product, even cars..) : it’s going to be trade-offs for benefits vs downsides

Are you strictly talking about on disk management of assets ? Edit: no you’re not, but I will, as it has repercussions beyond inventory systems.

First thing, is to put everything in version control. Assuming you don’t have budget for whatever is the current popular asset management solution at studios nowadays, you can use Git for binary files, you just don’t get meaningful diffs on them. Have your artists, level editors, etc. use commit messages to document the changes, or a text file called nameofasset.changes and have them update it, only ever adding to it to document changes.

As for folders organisation, i like having a core folder, with all the scripts and assets that are used everywhere in your game.

Then, I like to break it up by chapters, then levels, then player, ui, enemies, props, etc. With each of those having subfolders for scripts, textures, sounds, models,etc.

I like this approach better than a top level models, textures, etc. division cause it makes for smaller list of textures in a localized context that is self documenting.

Top level core is also very useful if you’re considering modding, or not putting too many hurdles to people modding your game.

Also consider some kind of server vs client separation, especially if they cohabit in the same install.

Again, there is as many solutions as there are games multiplied by game developing teams. I prefer a deeper asset tree that has smaller item count self documenting folders.

Cheers, hope that helps

Thanks for the info, but I’ve used Git many years for other software projects so I’m familiar with managing shared code.

I’m primarily interested in managing the resources in code and various methods for tracking them within the game.

I believe resources are the best way to handle things like inventory. They can be used just like any other data type in objects like arrays and dictionaries, and are very convenient when passing large amounts of signal data.

I define almost all of the resources I use purely in script. The resources that need them have methods for handling their data. For example, my resources that manage groups know how to iterate between the members.

Resources are one of the things I like best in Godot.

Yeah, I’m already using Resources.

But I’m looking for Best Practices for managing/tracking resources, including initial setup and in conjunction with player inventory.