state-machine

Organize Unity gameplay behavior into typed finite state machines.

3|Updated Jun 27, 2026
One-click install
npx skills add https://github.com/OmerZeyveli/kinglet-unity --skill state-machine-omerzeyveli
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: state-machine
Source: https://github.com/OmerZeyveli/kinglet-unity/tree/main/.claude/skills/gameplay/state-machine
Command: npx skills add https://github.com/OmerZeyveli/kinglet-unity --skill state-machine-omerzeyveli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps structure complex gameplay and game-flow behavior into clear, maintainable states and transitions instead of tangled conditional logic.

Core Features & Use Cases

  • Generic State Machines: Define reusable state contracts, typed transitions, lifecycle methods, and owner-aware state logic.
  • Gameplay and AI Patterns: Implement player movement states, enemy patrol and chase behavior, menu and pause flows, and event-driven transitions.
  • Advanced Organization: Use hierarchical state machines, explicit transition rules, ScriptableObject-driven configuration, state pooling, and isolated unit testing for scalable Unity systems.

Quick Start

Ask the state-machine skill to design and wire a typed hierarchical state machine for the specified Unity gameplay behavior.

Frequently Asked Questions about state-machine

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

FAQPage Schema
How do I structure Unity enemy AI without tangled conditional logic?▼

Structuring Unity enemy AI with a finite state machine organizes patrol and chase behaviors into typed state contracts, lifecycle callbacks, and explicit transition rules. This approach replaces tangled conditional logic with maintainable, isolated C# implementations.

What is a hierarchical state machine and when do I need it for Unity gameplay?▼

A hierarchical state machine nests sub-states within parent states to organize complex gameplay behaviors. You need it when player controllers or enemy AI require layered behaviors, allowing event-driven transitions without duplicating logic across independent states.

How to build a testable state machine for Unity player controllers?▼

Build a testable state machine by using plain C# implementations with typed state contracts and reusable state instances. Isolating state logic from Unity dependencies enables robust unit testing of player movement states and explicit transition management.

Can I use ScriptableObject-driven configuration for Unity state transitions?▼

Yes, you can use ScriptableObject-driven configuration to define explicit transition rules and state behaviors. This allows designers to manage event-driven transitions and gameplay flows directly from the Unity Inspector without modifying code.

Does this state machine approach work for Unity menu and pause flows?▼

Yes, this state machine approach works for Unity menu and pause flows by organizing game-flow behavior into maintainable states. Typed state contracts and lifecycle callbacks manage UI transitions and pause logic cleanly, avoiding nested boolean flags.

When should I not use a finite state machine for Unity gameplay?▼

You should avoid a finite state machine for simple Unity gameplay behaviors that require only a few conditional checks. Overhead from typed state contracts and lifecycle callbacks is unnecessary unless managing complex player movement, enemy AI, or hierarchical behaviors.