godot-state-machine-advanced

Implements hierarchical state machines and pushdown automata for Godot AI and character behaviors.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/DecioLuvier/Shatterless --skill godot-state-machine-advanced-decioluvier
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: godot-state-machine-advanced
Source: https://github.com/DecioLuvier/Shatterless/tree/main/.claude/skills/godot/references/godot-state-machine-advanced
Command: npx skills add https://github.com/DecioLuvier/Shatterless --skill godot-state-machine-advanced-decioluvier

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Flat finite state machines break down when Godot characters or AI need nested sub-states, interrupt overlays like stun or pause menus, and safe transition validation, leading to state spaghetti and lifecycle bugs. ## Core Features & Use Cases - Hierarchical State Machines: Delegate physics and input processing to nested sub-states such as Move, Air, and Attack children. - Pushdown Automata: Push interrupt states like stun, dialogue, or menus onto a stack and resume the previous state with re-entry awareness. - Transition Guards and Context: Validate transitions to block illegal state changes and pass persistent data between states via decoupled context objects. - Use Case: Build a combat character where locomotion and weapon handling run as concurrent machines, hit-stun pushes onto the state stack, and an AnimationTree syncer travels to matching animations on every state change. ## Quick Start Ask the agent to implement a hierarchical state machine with pushdown stun handling for a Godot character using the provided HSM scripts.

Frequently Asked Questions about godot-state-machine-advanced

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a hierarchical state machine in Godot?▼

Create child state nodes under a parent machine and forward physics_update and handle_input calls from the parent to the active child each tick. Use the hsm_hierarchical_base.gd script as the delegator and keep nesting under three levels to avoid state spaghetti.

What is a pushdown automaton used for in game AI?▼

A pushdown automaton stacks interrupt states like stun, pause menus, or dialogue over gameplay states, then pops back to resume the previous state. Every push_state call needs a corresponding pop_state plan, and resumed states receive an is_resume message flag.

When should I use a behavior tree instead of a state machine in Godot?▼

Use a behavior tree or utility AI when logic requires nesting deeper than three levels or scoring many possible actions each tick. HSMs suit exclusive layered states, while utility cost polling fits agents picking the best action by weight.

Why does my Godot state machine crash during transitions?▼

Re-entrant transition_to calls inside enter() cause recursion crashes, and calling enter() without a prior exit() leaks timers and tweens. Use call_deferred for immediate sub-transitions and always pair exit before enter.

How do I sync Godot AnimationTree with state machine states?▼

Connect a syncer node to the state machine's state_changed signal and call travel() on the AnimationNodeStateMachinePlayback using the new state name. This keeps animation logic decoupled from state enter and exit bodies.