ge cs-state-machine

Installation
SKILL.md

GECS State Machine in Godot 4.3+

Implement character states and state transitions using GECS v9. In traditional Godot OOP, state machines are often implemented as hierarchies of Node children. In GECS, state is managed through pure data: either via Property-Based States (enums/strings in a component) or Component-Swapping States (adding/removing state components via cmd), taking advantage of archetype cache locality.

Addon: GECS · version v9 · Godot 4.3+ · MIT
Related skills: gecs-core for primitives, gecs-systems for cmd CommandBuffer mutations, gecs-queries for state filtering, gecs-observers for .on_match()/.on_unmatch() state enter/exit triggers.


1. State Pattern Comparison in ECS

Pattern How It Works Archetype Transition Best Suited For
Property-Based State State stored as an enum/flag inside a single component (C_CharacterState.state) No (Zero transition overhead) Rapidly changing states (Idle, Run, Jump, Fall, Walk), platformer locomotion
Component-Swapping State Entity gains/loses distinct state components (C_Stunned, C_Dashing, C_Invulnerable) Yes (1 coalesced move via cmd) Mutually exclusive systems, gating entire systems (e.g. StunSystem only queries C_Stunned)
Orthogonal / Layered State Multiple independent components (e.g. Locomotion + Combat + Status) Minimal Action RPGs, games with simultaneous movement and shooting
Traditional Node FSM (Anti-pattern) Node children per state (StateIdle extends Node) N/A Avoid in ECS: Breaks archetype cache, adds Node overhead

Installs
–
First Seen
–