game_state_machines

Design and manage game state machines for Godot C# projects.

2|Updated Jul 2, 2026
One-click install
npx skills add https://github.com/Xyrces/godot-ecs-gamedev-playbook --skill game-state-machines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: game_state_machines
Source: https://github.com/Xyrces/godot-ecs-gamedev-playbook/tree/main/skills/game_state_machines
Command: npx skills add https://github.com/Xyrces/godot-ecs-gamedev-playbook --skill game-state-machines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you structure complex game behavior into clear, maintainable state logic instead of scattered conditionals and hard-to-debug flow control. It is especially useful when enemies, UI, and gameplay all need coordinated transitions with predictable rules.

Core Features & Use Cases

  • Finite State Machines: Model simple entity behavior such as idle, patrol, chase, attack, hurt, and dead states.
  • Hierarchical State Machines: Share behavior through superstates so common logic like taking damage or handling stun can live above specialized substates.
  • Pushdown State Stacks: Manage menus, pause screens, dialogs, and overlays while preserving gameplay history underneath.
  • ECS Integration: Store state as component data and process transitions inside engine-agnostic systems.
  • Debugging and Guarding: Add transition guards, lifecycle hooks, logging, and visualization to prevent invalid or hidden state bugs.
  • Use Case: Use this Skill to design an enemy AI that switches between idle, chase, and attack states while also handling stun, death, and debug tracking cleanly.

Quick Start

Ask the AI to design a game state machine for your Godot C# project using FSM, HFSM, or pushdown patterns, and include ECS-friendly transition logic and guard rules.

Frequently Asked Questions about game_state_machines

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

FAQPage Schema
How do I structure enemy AI behavior with a finite state machine in Godot C#?

You can structure enemy AI behavior using a finite state machine to model distinct states like idle, patrol, chase, and attack. This approach replaces scattered conditionals with clear, maintainable, and predictable state transitions.

What is a hierarchical state machine and when do I need it for game flow control?

A hierarchical state machine organizes states into parent-child relationships so common logic like taking damage or stun handling can live in superstates above specialized substates. You need it when multiple entities share overlapping behaviors and you want to avoid duplicating transition rules.

How do I manage pause screens and dialog overlays without losing the underlying gameplay state?

You manage pause screens and dialog overlays using a pushdown state stack. This pattern preserves your underlying gameplay history by stacking overlay states, allowing the game to resume the exact previous state when the overlay is popped.

Can I integrate state machine transitions with an ECS architecture in Godot?

Yes, you can integrate state machine transitions with an ECS architecture in Godot. The system stores state as component data and processes transitions inside engine-agnostic systems, ensuring deterministic state updates that work cleanly with ECS-driven game logic.

How do transition guards and lifecycle hooks prevent invalid state bugs?

Transition guards prevent invalid state bugs by enforcing strict rules that block unauthorized state changes before they execute. Lifecycle hooks add logging and visualization at state entry and exit points, making hidden or illegal transitions immediately visible during debugging.

Does game_state_machines support debug visualization for tracking state updates?

Yes, game_state_machines supports debug visualization for tracking state updates. It provides logging and visualization tools alongside lifecycle hooks and transition guards, allowing you to monitor deterministic state changes and identify invalid flow control during development.