About unity-fsm
unity-fsm is a modular, object-oriented finite state machine skill for Unity, aligned with the implementation used in Adam Myhre's 3D Platformer. It provides state, transition, timer, and detection patterns for player and enemy logic.
Key features
- 01Class-based state machine foundation
- 02Heavy and ActionState state support
- 03Predicate-based transitions
- 04CountdownTimer and StopwatchTimer
- 05Detection strategies and AI templates
Use cases
- 01Structuring player controller states
- 02Building enemy AI state flows
- 03Adding predicate-driven state transitions
- 04Managing AI cooldowns and detection
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ muharremtozan/ unity-agent-skills --skill unity-fsmAfter installing, type/unity-fsmin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
assets/code/ActionState.cs.txtBaseState.cs.txtConeDetectionStrategy.cs.txtEnemy.cs.txtEnemyBaseState.cs.txtFuncPredicate.cs.txtIDetectionStrategy.cs.txtIPredicate.cs.txtIState.cs.txtITransition.cs.txtPlayerDetector.cs.txtStateMachine.cs.txtTimer.cs.txtTransition.cs.txtreferences/enemy-ai.mdguide.mdDetails
From the project READMEUnity Finite State Machine (FSM)
This skill provides a modular, object-oriented State Machine architecture for Unity, specifically refactored to match the implementation in Adam Myhre's 3D Platformer.
Core Features
- Object-Oriented: Each state is a dedicated class.
- Hybrid Support: Support for both "Heavy" (classes) and "Light" (
ActionState) states. - Strategy-Based Transitions: Uses Predicates and Detection Strategies.
- Timer System: Includes Adam Myhre's
CountdownTimerandStopwatchTimer. - Namespace Support: Uses
PlatformerandUtilitiesnamespaces.
Core Files (assets/code/)
IState.cs.txt,StateMachine.cs.txt,IPredicate.cs.txt: Base FSM logic.ActionState.cs.txt: New! Lambda-based state to reduce boilerplate.Timer.cs.txt: AI cooldown management.IDetectionStrategy.cs.txt,ConeDetectionStrategy.cs.txt: Sensing logic.PlayerDetector.cs.txt,Enemy.cs.txt,EnemyBaseState.cs.txt: AI templates.
Usage Guides
- GUIDE.md: General FSM setup and wiring.
- ENEMY-AI.md: Specific guide for implementing AI with Detection Strategies.
Implementation Pattern
- Define your states by inheriting from
BaseState. - Wire them in your
PlayerControllerorEnemyAIusingstateMachine.AddTransition. - Execute via
Update()andFixedUpdate()calls to the machine.
Comments
Markdown supported