Hello.
I am currently re-organizing my project files and folders, I am a bit confused by how to organize tscn and script file in a project, these are the 2 approaches I am currently planning to use:

  1. Separated scripts and scenes files(like in Unity)
    -root folder
    --assets
    ---scenes
    ----objects (tscn only)
    ----levels (tscn only)
    ----blahblahs (tscn only)
    ---scripts
    ----objects (.gd file only)
    ----levels (.gd file only)
    ----blahblahs (.gd file only)

  2. One Object per folder:
    --assets
    ---objects
    ----player (player.tscn and player.gd)
    ----mobs (mob.tscn and mob.gd)
    ----blahblah ( blahblah.tscn and blahblah.gd)

So which one is optimal in a long run?
Or is there a 'rules/standards' for organizing such files that is better than the 2 approaches listed above

Thanks

  • Don't separate .gd scripts from .tscn files in every case, you'll just go mad. I made that mistake on a past project and it was a waste of time and made everything more confusing.

    There is a use case for it in parts of the project though.

    I'd recommend #2 but with categories, limiting 2 files per folder is overkill, for example you can put all "vehicles" gd/tscn in one folder, etc.

    One note is "assets" such as "art" folder will appear first in searches. That can be annoying when you have tons of art with the same name as your code file you're trying to find, because they will appear first and you'll need to scroll down. If you can find another name for it you like, lower in the alphabet, such as "resources" it will help in the long run IMO

There are really no rules. Use the system that looks most logical to you. Chances are you'll have to reorganize several times anyway as the project grows larger.

Both approaches seem fine to me, it's probably more up to which might work better for your project and that's something that I can't really comment on.

Don't separate .gd scripts from .tscn files in every case, you'll just go mad. I made that mistake on a past project and it was a waste of time and made everything more confusing.

There is a use case for it in parts of the project though.

I'd recommend #2 but with categories, limiting 2 files per folder is overkill, for example you can put all "vehicles" gd/tscn in one folder, etc.

One note is "assets" such as "art" folder will appear first in searches. That can be annoying when you have tons of art with the same name as your code file you're trying to find, because they will appear first and you'll need to scroll down. If you can find another name for it you like, lower in the alphabet, such as "resources" it will help in the long run IMO

GDQuest and others organize like:

vehicles -> gd\tscn
vehicles -> assets -> pngs / sound / etc

You can check their stuff out and see. Personally I prefer all art/etc assets to be separated from code

I haven't figured this out yet, but it generally gets out of hand because world scenes need to be kind of main categories, and supporting scenes for each world in that folder, and then a folder for shared scenes that are used in more than one world. That's my idea so far that hasn't been used yet, but generally it's when you get too many world scenes that it gets messy. And then good naming practices help a lot also.

Thanks for the replies, guys.

Seems #2 is overally better from the advices and examples everyone provided... though I am also using the Godot-Stuff ECS 4.0 plugin from paul hocker, which make every game object like this:

Vehicle tscn
-component wheel
-component body
-component horn
-component etc

Every component is a node with a 'component' script attached, and most components are resuable or universal in some way (e.g: shared by multiple objects), so I think keeping a copy of such node scene/script is probably not desirable for each object that uses them.

5 days later

Here is what the official documentation says about it:

Project organization

/project.godot
/docs/.gdignore # See "Ignoring specific folders" below
/docs/learning.html
/models/town/house/house.dae
/models/town/house/window.png
/models/town/house/door.png
/characters/player/cubio.dae
/characters/player/cubio.png
/characters/enemies/goblin/goblin.dae
/characters/enemies/goblin/goblin.png
/characters/npcs/suzanne/suzanne.dae
/characters/npcs/suzanne/suzanne.png
/levels/riverdale/riverdale.scn