Godot project organizing

Godot uses a hierarchical structure to build a game. A game must have at least 1 scene with 1 script. Without a scene, nothing can be shown on screen. Typically a game will have a Main scene, where everything is connected i.e. player, spawned enemies, score etc.

Scenes, scripts, fonts, graphics and sounds are all resources in a Godot project. Resources are stored within the project at ‘res://‘. This means that by default all files will be stored in the same location. That might be ok, with small projects (less than 20 resource files in total). But a project usually have a tendency to grow bigger than that very quickly.

So even though, there are no enforced rules on how to structure your game resources, there are some good practice guide lines.

  • Graphics, music and shaders are usually regarded as ‘assets’.
  • Scenes and their accompanying scripts are usually stored together. If you want to store your scenes and their scripts together, it’s recommended to divide them into subfolders i.e. ‘res://scenes/player/‘ etc.
  • If wanted, all scripts (including scene scripts) can be stored in a ‘scripts’ folder. However, don’t mix reusable scripts (scripts used across different projects) in with the your game scripts.

Here’s an example of resource structuring.

  • res://
    • scenes/’ – All scene files and possibly scripts.
      • player/‘ – Player scene.
      • enemy/‘ – Enemy scenes.
      • main/‘ – Main scene.
      • hud/’ – HUD scenes.
      • levels/‘ – Level scenes.
      • UI/‘ – UI scenes.
      • menu/‘ – Menu scenes.
      • etc.
    • scripts/’ – All script files.
      • player/‘ – Player controller code.
      • AI/‘ – AI scripts.
      • enemy/‘ – Enemy logic.
      • inventory/‘ – Inventory system.
      • input/‘ – Input handling.
      • etc.
    • assets/‘ – All visual/audio/artistic.
      • sprites/‘ – Image files for textures (*.png, *.jpg).
      • tilesets/‘ – Tileset graphics.
      • UI/‘ – UI elements.
        • icons/‘ – UI icons.
        • etc.
      • background/‘ – Background/parallax graphics.
      • fonts/‘ – Fonts
      • models/‘ – 3D models (*.obj, *.glb).
      • materials/‘ – Material files (*.tres).
      • audio/‘ – Music, effects, ambient etc.
        • music/‘ – Background music.
        • effects/‘ – Sound effects (laser, explosions etc.)
        • ambience/‘ – Ambient sounds (rain, wind etc.)
        • etc.
      • shaders/‘ – Shader files (*.gdshader).
      • animations/‘ – Animations.
      • etc.
    • autoloads/‘ – Global singleton scripts (GameState, AudioManager, SaveManager etc.)

This way we keep a clear and easy overview of our game resources.

It’s not necessary to create this resource structure from the beginning. As your game grows, you can organize your resources. You can add folders and reorganize files at any time. The Godot project will keep track of your files.