I'm working on a project that's scaling up a bit fast in term of files and content. As such I need a way to keep these files organized.
The godot documentation recommends keeping resources and assets close to their scenes. I used to do the opposite, separating assets by type and linking them in my scenes.
Now, what the docs recommend is good but how to avoid duplications when you need to use the same resource at multiple places?
Say you have a gunshot sound, your player can use it, your enemies too.
Option A (the docs way):
/enemies/cowboy/gunshot.ogg
/enemies/cowboy/cowboy.tscn
/enemies/turret/gunshot.ogg
/enemies/turret/turret.tscn
/player/gunshot.ogg
/player/player.ogg
Here I have a redundancy of gunshot.ogg, so if later I want to edit the sound, I have to remember to swap it at 3 different places.
But on the other hand, the scenes are better "packed" for reusability on other projects and it "feels right"
Option B (my way):
/gameobjects/player.tscn
/gameobjects/cowboy.tscn
/gameobjects/turret.tscn
/sounds/gunshot.ogg
Here my naive way reduces redundancy, if I want to update the gunshot sound, I can just replace the one under /sounds/. The project is smaller which is also a (very) good benefit.
However, if I want to make another game, reusing those scenes is a pain because I'm dealing with missing resources and finding who needs what to work.
Is there a middle ground method, some Option C I'm not seeing?
Thank you for reading ^^
In the problem of files organisation, this seems to only push it elsewhere.
Because now, if I make another game with my cowboy for example, I need to remember to take the shooting component with me. And all other components I would have made linked to this cowboy.
This would look like:
I guess this mitigates the issue at least ๐ค
If you want to replicate stuff across multiple separate projects, I guess the best method would be to create your own plugins: https://docs.godotengine.org/en/stable/tutorials/plugins/editor/making_plugins.html
For example you could assemble all of your custom components, including assets like sound effects, into a plugin that serves as a library of reusable components. Then you'd only need to add the plugin to whatever project you need them in and Godot would automatically take care of the file management.