uw-state-machine

Manage Unity game, AI, and UI state transitions with IState interfaces.

40|6|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/devdavv/unity-ai-workflow --skill uw-state-machine
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: uw-state-machine
Source: https://github.com/devdavv/unity-ai-workflow/tree/main/.claude/skills/uw-state-machine
Command: npx skills add https://github.com/devdavv/unity-ai-workflow --skill uw-state-machine

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing game, AI, and UI state transitions in Unity can become error-prone as complexity grows. This Skill provides a clean, interface-based approach to define states, transitions, and lifecycle behavior for consistent game flow.

Core Features & Use Cases

  • Interface-driven state definitions with IState and IUpdatableState
  • A reusable StateMachine that ensures a single active state and supports asynchronous transitions
  • Clear guidance for DI-first (uw-dependency-injection) or SO-first integration in Unity projects
  • Practical patterns for GameFlow (menu -> gameplay -> game over), Character States (Idle/Run/Jump), and UI Screen Flows
  • Best practices for cancellation tokens, cleanup, and error handling

Quick Start

Create a StateMachine, define initial states, and wire up a Lobby -> GamePlay -> GameOver flow in your Unity project.

Frequently Asked Questions about uw-state-machine

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

FAQPage Schema
What is the best way to structure asynchronous state machines for Unity game flow?

Asynchronous state machines for Unity game flow are structured using an IState or IUpdatableState interface alongside a StateMachine orchestrator. This ensures a single active state and supports clean transitions from menu to gameplay to game over.

How do I set up a Unity state machine for character behaviors and UI screen flows?

To set up a Unity state machine for character behaviors and UI screen flows, define states using IState, wire them into a reusable StateMachine, and apply practical patterns for transitions like Idle/Run/Jump or menu navigation.

Do I need dependency injection to use state machines in my Unity project?

You do not strictly need dependency injection to use state machines in your Unity project. The Skill provides clear guidance for both DI-first integration via uw-dependency-injection and ScriptableObject-first integration defined in ProjectConfig.yaml.

How do I handle cleanup and cancellation tokens when transitioning between game states?

Handling cleanup and cancellation tokens during Unity game state transitions is managed through built-in best practices for asynchronous operations. The StateMachine orchestrator ensures previous states are properly cleaned up before activating new ones.

Why does my Unity state machine throw errors when switching UI screens rapidly?

Errors when rapidly switching Unity UI screens are prevented by the StateMachine's enforcement of a single active state and its asynchronous transition handling. Proper use of cancellation tokens ensures safe state lifecycle management during overlapping requests.

Can I use this state machine approach for AI behaviors in Unity?

Yes, you can use this state machine approach for AI behaviors in Unity. The interface-driven IState and IUpdatableState definitions support complex AI state transitions alongside standard game flow and UI screen management.