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

godot-signals-groups

하는 일

이 스킬은 시그널을 통해 Godot 게임 요소들이 서로 소통하는 방법과, 그룹을 통해 많은 노드를 한 번에 제어하는 방법을 설명합니다. 더 깔끔한 프로젝트 구조를 원하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓플레이어 사망처럼 게임의 한 부분이 다른 부분에 무언가 일어났음을 알려야 할 때.
  • ✓한 그룹의 객체 전체를 한 번에 일시 정지하거나 저장하고 싶을 때.
  • ✓Godot 프로젝트에서 씬 사이의 직접 연결을 시그널로 바꾸고 있을 때.

스킬 링크

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-signals-groups/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-signals-groups/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분.

작동 방식

자식 객체가 위로 시그널을 보내는 방법, 다른 객체가 이를 연결하는 방법, 그룹으로 한 번의 호출로 많은 노드에 작업하는 방법을 설명합니다.

기술 내용 (원본 SKILL.md)

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

Godot Signals & Groups (4.x)

Decouple nodes with the observer pattern (signals) and act on many nodes at once (groups), instead of hard-coding references between scenes. Targets Godot 4.7.

When to use

  • Use when a node needs to tell others "something happened" (player died, item picked up, wave cleared) without holding direct references to them.
  • Use when you need to address a whole category of nodes at once ("pause all enemies", "save every checkpoint").

When not to use: raw signal syntax basics → godot-gdscript; scene structure and instancing → godot-nodes-scenes. For cross-scene global events, emit from an autoload (see godot-nodes-scenes).

Core workflow

  1. Decide the direction. A child/sub-scene should emit a signal upward; the parent connects to it. This keeps the child reusable and ignorant of who listens.
  2. Declare typed signals on the emitter; emit() them when the event occurs.
  3. Connect with a Callable (sig.connect(_on_sig)), optionally in the editor's Node dock. Use CONNECT_ONE_SHOT for fire-once, bind() to pass extra context.
  4. Use groups for broadcast: add nodes to a named group, then iterate get_tree().get_nodes_in_group(...) or call_group(...).
  5. Disconnect when needed (e.g. before freeing a long-lived listener) and check is_connected() to avoid duplicate connections.

Patterns

1. Emit upward, connect from the parent

# coin.gd (reusable pickup — knows nothing about the player or HUD)
extends Area2D
signal collected(value: int)

func _on_body_entered(body: Node) -> void:
    if body.is_in_group("player"):
        collected.emit(10)
        queue_free()
# level.gd (the parent wires the coin to game state)
func _ready() -> void:
    for coin in get_tree().get_nodes_in_group("coins"):
        coin.collected.connect(_on_coin_collected)

func _on_coin_collected(value: int) -> void:
    GameState.add_score(value)

2. Connect flags: one-shot and bind extra arguments

func _ready() -> void:
    # Fire exactly once, then auto-disconnect.
    $Door.opened.connect(_on_door_opened, CONNECT_ONE_SHOT)
    # bind() appends arguments supplied at connect time (after the signal's own args).
    $RedButton.pressed.connect(_on_button.bind("red"))

func _on_button(color: String) -> void:
    print("Pressed the %s button" % color)

3. Groups: broadcast to many nodes

func pause_all_enemies() -> void:
    # Call a method on every node in the "enemies" group (no-op if missing).
    get_tree().call_group("enemies", "set_paused", true)

func count_enemies() -> int:
    return get_tree().get_nodes_in_group("enemies").size()

Add a node to a group from code or via the editor's Node > Groups tab:

func _ready() -> void:
    add_to_group("enemies")        # remove_from_group("enemies") to leave

4. Await a signal inline

func open_chest() -> void:
    $AnimationPlayer.play("open")
    await $AnimationPlayer.animation_finished   # pause until it emits
    spawn_loot()

Pitfalls

  • 3.x connect signature is gone. connect("died", self, "_on_died") → died.connect(_on_died). The target is implied by the Callable. The legacy Object.connect("died", Callable(self, "_on_died")) works but the method-name string form does not.
  • Duplicate connections fire handlers multiple times. Connecting again in _ready() after re-adding a node stacks callbacks. Guard with if not sig.is_connected(cb): sig.connect(cb).
  • Connecting to a freed node errors. Godot removes a connection when the emitter or the Callable's owner is freed, but a lambda belongs to the script that created it — one that captures a node freed later keeps firing and errors. Connect listener methods, or disconnect stored lambdas yourself.
  • Groups are global to the SceneTree, not per-scene. Two levels using the same group name share membership. Namespace group names if that matters.
  • call_group silently ignores nodes lacking the method. Typos in the method name fail quietly — prefer a typed signal when the contract matters.
  • Signal args must match the handlers. emit() does not validate arguments against the signal declaration; a handler with a different argument count fails with "Method expected N argument(s)" at emit time. Declare typed params and emit exactly those.

References

  • For connection flags, deferred c
자주 묻는 질문

시그널이란 무엇인가요?

시그널은 무언가 일어났을 때 노드가 보내는 메시지이며, 다른 노드가 이에 반응할 수 있습니다.

그룹이란 무엇인가요?

그룹은 이름이 붙은 노드 묶음으로, 예를 들어 모든 적처럼 함께 다룰 수 있습니다.

기본 GDScript 문법도 설명하나요?

아니요. 기본 문법은 별도의 GDScript 스킬에서 다룹니다.

상세 정보

작성자의 원본 설명

Build event-driven, decoupled Godot 4.7 gameplay with signals and node groups: declare and emit custom signals, connect with Callables (incl. bind/one-shot), and broadcast to many nodes via groups and call_group. Use when wiring node communication in a Godot project, replacing tight references with signals, emitting/connecting events, or porting 3.x connect("sig", self, "method") code.

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

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬