From atum-gamedev
Godot 4 game engine pattern library — GDScript 2 (typed) + GDExtension (C++ for performance hot paths) + C# (Mono build), Scenes + Nodes + Signals architecture (composition over inheritance via packed scenes), Autoload singletons (config, audio, scene transitions, save manager), Resources + custom Resource classes (data-driven design like Unity ScriptableObjects), AnimationPlayer + AnimationTree + StateMachine playback, Tween + Easing for scripted animations, Physics 2D / 3D (RigidBody, CharacterBody, Area, RayCast), Navigation 2D / 3D + NavigationMesh baking, Tilemap + TerrainSet for level design, Input mapping (InputMap actions in Project Settings), Theme system for UI, Control nodes hierarchy (anchors / containers / theme overrides), Forward+ vs Mobile vs Compatibility renderer choice, GLES3 / Vulkan / Metal backend, Shader language (visual ShaderGraph or text .gdshader), GDExtension for native libraries (replaces deprecated GDNative), export templates per platform (Windows/Linux/Mac/Android/iOS/HTML5), and Godot 4 LSP for VS Code. Use when developing Godot 4 games (2D platformer, 3D RPG, mobile, web HTML5), choosing between GDScript / C# / GDExtension, structuring scenes hierarchically, or auditing performance. Differentiates from Unity patterns by Godot-specific node tree paradigm and signal-based event system.
npx claudepluginhub arnwaldn/atum-plugins-collection --plugin atum-gamedevThis skill uses the workspace's default tool permissions.
Patterns canoniques pour développer sur **Godot 4.x** (2026 LTS) avec **GDScript 2 typé**.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides agent creation for Claude Code plugins with file templates, frontmatter specs (name, description, model), triggering examples, system prompts, and best practices.
Patterns canoniques pour développer sur Godot 4.x (2026 LTS) avec GDScript 2 typé.
Player.tscn (CharacterBody2D)
├── CollisionShape2D
├── Sprite2D
├── AnimationPlayer
├── HealthComponent (Node, custom)
├── InventoryComponent (Node, custom)
└── HitboxComponent (Area2D, custom)
# Player.gd
extends CharacterBody2D
class_name Player
@export var speed: float = 300.0
@export var jump_velocity: float = -400.0
@onready var health: HealthComponent = $HealthComponent
@onready var inventory: InventoryComponent = $InventoryComponent
@onready var animation: AnimationPlayer = $AnimationPlayer
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity.y += get_gravity().y * delta
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_velocity
var direction := Input.get_axis("move_left", "move_right")
velocity.x = direction * speed
move_and_slide()
_update_animation(direction)
func _update_animation(direction: float) -> void:
if not is_on_floor():
animation.play("jump")
elif direction != 0:
animation.play("run")
else:
animation.play("idle")
Pattern de composition : au lieu d'une grosse classe Player, on attache des composants (HealthComponent, InventoryComponent, HitboxComponent) qui exposent leur API via méthodes/signaux. Réutilisable sur Enemies, NPCs, Objects.
# HealthComponent.gd
extends Node
class_name HealthComponent
signal health_changed(new_health: int, max_health: int)
signal died
@export var max_health: int = 100
var current_health: int : set = _set_health
func _set_health(value: int) -> void:
current_health = clamp(value, 0, max_health)
health_changed.emit(current_health, max_health)
if current_health <= 0:
died.emit()
func take_damage(amount: int) -> void:
current_health -= amount
func heal(amount: int) -> void:
current_health += amount
# UI HUD subscribe au signal
func _ready() -> void:
player.health.health_changed.connect(_on_health_changed)
player.health.died.connect(_on_player_died)
func _on_health_changed(current: int, max_health: int) -> void:
health_bar.value = float(current) / max_health * 100
Project Settings → Autoload → ajouter les scripts globaux :
# game_state.gd (autoload as "GameState")
extends Node
var current_score: int = 0
var current_level: int = 1
var player_data: PlayerData
signal score_changed(new_score: int)
signal level_completed
func add_score(amount: int) -> void:
current_score += amount
score_changed.emit(current_score)
func reset() -> void:
current_score = 0
current_level = 1
# Utilisation depuis n'importe quel script
func collect_coin() -> void:
GameState.add_score(10)
Bons candidats autoload : GameState, AudioManager, SceneTransition, SaveLoadManager, EventBus.
Mauvais candidats : tout ce qui est spécifique à une scène ou un niveau.
# weapon_data.gd
extends Resource
class_name WeaponData
@export var weapon_name: String
@export var damage: int = 10
@export var fire_rate: float = 1.0
@export var icon: Texture2D
@export var fire_sound: AudioStream
Crée ensuite des .tres files dans l'éditeur :
weapons/sword.tres (damage=15, fire_rate=2.0)weapons/bow.tres (damage=8, fire_rate=4.0)# weapon.gd
extends Node
class_name Weapon
@export var data: WeaponData
func fire() -> void:
print("Firing %s, damage %d" % [data.weapon_name, data.damage])
Équivalent direct des ScriptableObjects Unity — données éditables sans recompilation, partagées sans duplication.
# Pour une animation simple, AnimationPlayer suffit
animation.play("attack")
animation.queue("idle") # joue idle après attack
# Pour state machine complexe, utiliser AnimationTree
@onready var animation_tree: AnimationTree = $AnimationTree
@onready var state_machine = animation_tree["parameters/playback"]
func _ready() -> void:
animation_tree.active = true
func attack() -> void:
state_machine.travel("attack") # transition propre vers "attack"
# CharacterBody2D pour les acteurs jouables (player, NPCs, ennemis)
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
| Type | Use case |
|---|---|
| CharacterBody2D/3D | Player, NPC, ennemis (control manuel) |
| RigidBody2D/3D | Objets physiques (boîtes, débris, projectiles) |
| StaticBody2D/3D | Plateformes, murs, sols |
| Area2D/3D | Triggers, hitboxes, pickups (no collision response) |
Godot 4 a refondu le système Tilemap. Workflow :
TileSet resourceTileMapLayer node# Export depuis CLI
godot --export-release "Windows Desktop" build/windows/game.exe
godot --export-release "Linux/X11" build/linux/game.x86_64
godot --export-release "macOS" build/mac/game.zip
godot --export-release "Android" build/android/game.apk
godot --export-release "iOS" build/ios/game.ipa
godot --export-release "Web" build/web/index.html
Exports nécessaires : télécharger les Export Templates pour la version exacte de Godot via Editor → Manage Export Templates.
| Langage | Use case |
|---|---|
| GDScript 2 typé | Default — 90% du gameplay |
| C# | Si l'équipe vient de Unity, utilisation des libs .NET, perf importante |
| GDExtension (C++) | Hot paths critiques (procedural mesh generation, physics custom, intégration libs C/C++) |
GDScript 2 typé est étonnamment performant grâce au compilateur Godot. Privilégier les types explicites :
# BAD
var enemies = []
func add_enemy(e):
enemies.append(e)
# GOOD
var enemies: Array[Enemy] = []
func add_enemy(e: Enemy) -> void:
enemies.append(e)
get_node("$Path/With/Many/Slashes") partout — utiliser @onready var x = $Path ou export_process au lieu de _physics_process pour les mouvements physiquesprocess_mode = INHERIT sur tout → ralentit le pause globalpre-import script sur les assets → reimport non-déterministeResource.duplicate(true) abusé → fuite mémoireset_physics_process(false) oublié sur entités hors écran — perf gâchéegame-multiplayer-patterns (ce plugin)game-asset-pipelines (ce plugin)unity-patterns (ce plugin)game-architect (ce plugin)godot-expert (ce plugin)