state-machine-architect

Generate Unity state machine systems using the State Pattern with hierarchical states.

71|11|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/nlelouche/Unity-SkillForge --skill state-machine-architect-nlelouche
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-machine-architect
Source: https://github.com/nlelouche/Unity-SkillForge/tree/main/.agent/skills/01-architecture/state-machine-architect
Command: npx skills add https://github.com/nlelouche/Unity-SkillForge --skill state-machine-architect-nlelouche

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill streamlines the creation of complex state-based logic in Unity, preventing the common pitfalls of tangled if/else statements and improving code maintainability for player controllers, AI, and UI systems.

Core Features & Use Cases

  • State Pattern Implementation: Generates robust, reusable state machine components using the State Pattern.
  • Hierarchical States: Supports nested states for advanced logic organization.
  • Context-Aware States: States can access and modify a shared context object.
  • Use Case: Implement a player character's movement system with distinct states like Idle, Walking, Running, and Jumping, each handling its own logic and transitions seamlessly.

Quick Start

Use the state-machine-architect skill to generate a state machine for player movement with Idle, Walk, Run, Jump states in the 'Game.Player' namespace.

Frequently Asked Questions about state-machine-architect

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

FAQPage Schema
How do I implement a state pattern for a Unity player controller without tangled if/else statements?

Hierarchical state machines in Unity support nested states, allowing you to organize advanced AI behaviors and player movement logic into parent-child relationships. This structure lets sub-states inherit transitions and context from parent states, keeping complex behavior trees maintainable.

Can I use this state machine system for Unity AI behaviors and UI flow management?

Yes, the state machine system is designed for Unity AI behaviors and UI flow management alongside player controllers. It generates flexible state pattern implementations using a shared context object that states can access and modify, making it suitable for any state-based logic system in your project.

What's the best way to structure context-aware states for a Unity state machine?

Structure context-aware states by implementing `IState<TContext>` or extending the optional `StateBase<TContext>` boilerplate class. States access and modify a shared context object passed through the generic type parameter, allowing seamless data sharing between player movement states like Walk, Run, and Jump.

How do I generate a Unity state machine with Idle, Walk, Run, and Jump states?

Generate a Unity state machine by requesting states like Idle, Walk, Run, and Jump within a specified namespace such as 'Game.Player'. The system produces modular state pattern components with hierarchical state support and transitions, each handling its own logic and movement behaviors seamlessly.

Does this state machine approach work for complex Unity player movement systems?

Yes, this state machine approach works for complex Unity player movement by organizing distinct states like Idle, Walking, Running, and Jumping. Each state handles its own logic and transitions independently through the modular state pattern, preventing code tangles and improving maintainability for intricate systems.