godot-gdscript
Use when the user asks about advanced GDScript, typed GDScript performance, Godot servers (RenderingServer, PhysicsServer), signals, threading in Godot 4 or…
от j4flmao★ 47 звёзд на GitHub
Установить godot-gdscript в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Godot Engine Internal Architecture & GDScript Deep Patterns
Purpose
Godot's performance and architecture come from its split between a high-level SceneTree (Nodes) and low-level Server singletons (RenderingServer, PhysicsServer3D, AudioServer). GDScript rides on top of a core that is C++-driven, with a message-passing signal system.
Agent Protocol
Trigger
"gdscript", "godot servers", "RenderingServer", "PhysicsServer", "godot signals", "godot threading", "godot performance".
Input Context
- Godot 4.x minor version
- GDScript, C# or GDExtension
- Performance symptom or architecture question
Output Artifact
GDScript code and architecture guidance. No file unless requested.
Response Format
Godot: {4.x}
Layer: {SceneTree | Server}
Code: {snippet}
Verify: {profiler / monitor numbers}
1. Server Architecture (The Core Split)
SceneTree (high-level)
Node2D/Node3D/Control... -> translate gameplay to server commands
| node.add_child(), set_transform(), play()
v
Servers (C++ singletons; most calls are safe from worker threads — see the "Thread-safe APIs" doc page)
RenderingServer -> BVH culling, batching, Vulkan/OpenGL backend
PhysicsServer3D -> solver, step
AudioServer -> mixer, spatialization
NavigationServer3D
Nodes do NOT render. A MeshInstance3D only holds an RID (resource ID) pointing into the server's storage; rendering calls become server commands queued and flushed in a controlled order. Decoupling keeps gameplay threads isolated from GPU work.
1.1 RIDs (Resource IDs)
Every server object is referenced by an opaque RID:
var rdr = RenderingServer
var mesh_id = rdr.mesh_create()
# rdr.camera_create(), rdr.instance_create()
Advanced systems bypass the Node layer by talking directly to servers — essential for massive 2D particles, custom culling, or pre-render batching.
1.2 Multi-Viewport & Rendering Priority
- Multiple viewports: main
rootwindow +SubViewportnodes, displayed through aViewportTexture. RenderingServerowns a broad "scene partition" (BVH) for culling; nodes register/unregister into it.
2. The Signal / MessageQueue System
Signals implement the Observer pattern at the engine core.
# emit
node.emit_signal("damage_taken", amount)
# connect
node.damage_taken.connect(func(dmg): _hp -= dmg)
2.1 Deferred (Queued) Signals — Safety
When two frames' iteration can't be interleaved (physics callbacks modifying the tree), CONNECT_DEFERRED pushes the payload into a MessageQueue:
body_entered.connect(_on_entered, CONNECT_DEFERRED)
The queue flushes at the end of the frame in SceneTree::process, so the modification happens AFTER iteration completes — preventing mid-iteration tree corruption. Use deferred for: freeing nodes during signal callbacks, structural changes inside physics step.
2.2 Signal vs Poll
- Signal: zero-cost when nothing listens; good for infrequent events (collisions, buttons).
- Poll:
_processchecking a flag on 60 nodes is cheap; re-designing everything to signals can add complexity. Balance: for high-frequency (per-frame movement) prefer polling local state; for rare cross-module changes use signals.
3. SceneTree Lifecycle & Queries
_ready(),_enter_tree,_exit_tree,_process(delta),_physics_process(delta),_input.get_tree().get_root(),get_tree().change_scene_to_file().- Node queries:
get_node(path),get_nodes_in_group(),get_children(). - Rule:
_processis called on every active node every frame — disable withset_process(false)for static branches.
4. GDScript Language Deep Dive
4.1 Typing & Performance
GDScript is dynamically typed but performance-sensitive:
@export var speed: float = 10.0 # typed
var dict := {"a": 1} # inferred
func move(dir: Vector2, dt: float) -> void: ...
- Typed locals are much faster than untyped.
- Hot loops: prefer typed loops, avoid dynamic
Dictionarylookups repeatedly. constwhen a value never changes.- Detection: the editor reports "untyped global" warnings; fix them.
4.2 Built-in Data Types
| type | use | notes |
|---|---|---|
Array |
dynamic list | resize(), typed variants via Array[int] |
PackedStringArray etc. |
contiguous, fast | for hot data prefer these |
Dictionary |
keyed | avoid per-frame churn |
Vector2/3, Transform2D/3D, Quaternion |
math | built-in, fast |
4.3 Memory & Pooling
- GDScript has no tracing GC.
RefCountedobjects (incl.Resource) are freed when the last reference drops — reference cycles leak (break them or useWeakRef). PlainObject/Nodeinstances must be freed explicitly (queue_free()/free()). - For 100s-1000s of short-lived entities write a small pool (an
Array[Node]of pre-instantiated, hidden nodes) and recycle instead of instantiate/free. - Prefer
preload("res://...")(compile-time) o
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл godot-gdscript?
Use when the user asks about advanced GDScript, typed GDScript performance, Godot servers (RenderingServer, PhysicsServer), signals, threading in Godot 4 or bypassing the SceneTree for speed. Produces low-level Godot 4 techniques and profiled optimisations. Not for general Godot project setup (use godot).
Как установить скилл godot-gdscript?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл godot-gdscript запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
slack-gif-creator
AnthropicKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
automate-this
GitHubAnalyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
from-the-other-side-vega
GitHubPatterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
plantuml-ascii
GitHubGenerate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…