본문으로 건너뛰기
Skillpedia
일반 코딩6.6k · #13825

godot-nodes-scenes

하는 일

이 스킬은 엔진의 기본 구성 요소인 노드와 씬으로 Godot 게임을 만드는 방법을 설명합니다. 깔끔한 프로젝트 구조가 필요한 게임 제작자를 위한 스킬입니다.

사용하는 경우

  • ✓Godot에서 캐릭터, 총알, 적, 메뉴를 위한 씬을 설계할 때.
  • ✓게임이 실행되는 동안 씬의 복사본을 만들고 싶을 때.
  • ✓노드를 찾을 수 없다거나 이미 삭제된 노드에 대한 오류가 보일 때.

스킬 링크

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-nodes-scenes/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-nodes-scenes/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“레벨에 여러 번 배치할 수 있는 재사용 가능한 적 씬을 Godot에서 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

작은 씬을 만드는 방법, 이를 재사용 가능한 템플릿으로 만드는 방법, 게임 실행 중에 추가하는 방법, 노드에 안전하게 접근하는 방법, 그리고 오토로드(autoload)라고 부르는 전역 도우미를 등록하는 방법을 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Godot Nodes & Scenes (4.x)

Compose games from nodes and scenes, instance them at runtime, and access the tree without crashing on freed or missing nodes. Targets Godot 4.7.

When to use

  • Use when structuring .tscn scenes, choosing how to break a feature into nodes, instancing a PackedScene (bullets, enemies, UI), or setting up autoload singletons.
  • Use when debugging get_node() / $Path returning null, or "Attempt to call on a previously freed instance".

When not to use: GDScript language/syntax → godot-gdscript; signal-based decoupling → godot-signals-groups; physics bodies/collisions → godot-physics.

Core workflow

  1. Model with composition. A scene is a tree of nodes saved as .tscn. Build small, single-purpose scenes (Player, Bullet, Enemy) and compose larger scenes from them. Favor adding child nodes over deep inheritance.
  2. Make a scene reusable by giving its root a script and exposing @export config. Save it; it becomes a PackedScene you can instance many times.
  3. Instance at runtime with preload/load → scene.instantiate() → add_child(instance). Set position/state after adding (or before, both work).
  4. Access nodes safely. Use @onready var x = $Path for fixed children; use unique names (%Name) for nodes deep in the tree; never assume a node still exists.
  5. Use autoloads for global state/services (game state, audio, scene switching) — registered in Project Settings > Globals (Autoload), accessible by name everywhere.
  6. Free nodes with queue_free() and guard later access with is_instance_valid().
  7. Check references before you finish. After creating, moving or renaming scenes, resources or scripts, run python scripts/check_godot_project.py <project-dir> (no Godot install needed; --json for machine-readable output). Fix every ERROR (missing or wrong-case res:// paths, undeclared ExtResource/SubResource ids, bad parent= paths, missing main scene or autoload) and re-run until it exits 0. Warnings such as a stale path= that Godot still finds by uid are safe but worth fixing. Run the script path relative to this skill directory, or resolve the installed skill path first. It needs Python 3.10+ and nothing else, and it does not replace opening the project in Godot.

Patterns

1. Instance a scene at runtime

extends Node2D

const BULLET := preload("res://bullet.tscn")   # preload: loaded at compile time

func shoot(at: Vector2, dir: Vector2) -> void:
    var bullet := BULLET.instantiate()         # create an instance of the scene
    bullet.global_position = at
    bullet.direction = dir                      # set exported/public state
    add_child(bullet)                           # now it's in the tree and runs

2. Safe node access: $, get_node_or_null, and unique names

@onready var label: Label = $UI/Label            # $ is sugar for get_node("UI/Label")
@onready var health_bar: ProgressBar = %HealthBar # % = scene-unique name (rename-proof)

func update() -> void:
    var optional := get_node_or_null("Maybe/Missing")  # returns null instead of erroring
    if optional:
        optional.queue_free()

3. An autoload singleton (global game state)

# game_state.gd — add in Project Settings > Globals > Autoload as "GameState".
extends Node

var score := 0
signal score_changed(value: int)

func add_score(points: int) -> void:
    score += points
    score_changed.emit(score)         # any scene can: GameState.score_changed.connect(...)

4. Change the running scene

func go_to_level_2() -> void:
    # Swaps the current scene for another. Frees the old scene tree.
    get_tree().change_scene_to_file("res://levels/level_2.tscn")
    # Or, with a preloaded PackedScene:
    # get_tree().change_scene_to_packed(LEVEL_2)

Pitfalls

  • $Path / get_node() return null or error when the path is wrong or the node isn't in the tree yet. Use @onready, verify the path matches the scene, or use get_node_or_null() for optional nodes.
  • Renaming a node breaks $Path. Use unique names (%Name, set via right-click

    Access as Unique Name) so deep references survive renames and reparenting.

  • free() mid-frame can crash other code still using the node. Prefer queue_free() (deletes at end of frame) and check is_instance_valid(node).
  • **Setting child state before `add
자주 묻는 질문

Godot에서 씬이란 무엇인가요?

씬은 저장된 노드 트리로, 재사용하거나 다른 씬 안에 배치할 수 있습니다.

오토로드란 무엇인가요?

오토로드는 게임 전체에서 계속 로드된 상태로 유지되는 전역 객체입니다. 예를 들어 공유 설정을 담는 객체가 있습니다.

물리도 다루나요?

깊게 다루지는 않습니다. 물리 바디와 충돌은 별도의 Godot 스킬에서 다룹니다.

상세 정보

작성자의 원본 설명

Structure a Godot 4.7 project with the scene tree and node composition: build reusable scenes, instance PackedScenes at runtime, navigate the tree safely, and register autoload singletons. Use when designing .tscn scenes, deciding how to split nodes, spawning instances with instantiate(), wiring autoloads, or fixing "node not found"/freed-node errors in a Godot project.

repo: gamedev-skills/awesome-gamedev-agent-skills

인기도

GitHub 스타
6.6k
순위
#13825
라이선스
Apache-2.0
업데이트
2026. 10. 28.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬