godot-scene-organization
Installation
SKILL.md
Scene organization in Godot 4
Scene, script or Resource
- Scene (
.tscn): a reusable tree of nodes with its own resources: a player, an enemy, a pickup, a UI panel, a level. Anything you place more than once or want to run alone (F6) is a scene. - Script (
.gd): behaviour attached to one node. Attach it to the root of the scene it controls, not to a parent that reaches into it. - Resource script (
extends Resourcewithclass_name): data without a node, such as item stats, wave definitions or save data, edited in the Inspector and saved as.tres.
A scene should work when run on its own. If it needs something from outside (a target, a spawn parent), expose it with @export or a signal instead of get_parent() chains.
Instancing scenes
extends Node2D
@export var enemy_scene: PackedScene
@export var spawn_parent: Node2D