# Inspiaaa/UnityHFSM

A fast, tried-and-tested hierarchical finite state machine library for Unity, designed to be easy to use yet powerful without compromising performance.

Repository: https://github.com/Inspiaaa/UnityHFSM
Canonical: https://ross.abutalabs.com/products/unityhfsm
Language: C#
License: MIT
License Family: permissive
Topics: fsm, csharp, unity3d, hierarchical, finite-state-machine, state-machine, unity, lightweight, coroutines, gamedev
Last push: 2026-03-25T17:02:04+00:00

## Health v2 (maintenance only)
Score: 72/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 74, release rhythm 52, longevity 100
- inputs: {"age_days": 2346, "days_push": 161, "days_rel": 163, "gap_med": 179.0, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1599, forks 155 (observed 2026-08-28T04:05:09.429004+00:00)

## What it is
UnityHFSM is a lightweight, hierarchical finite state machine library for the Unity game engine, written in C#. It supports both class-based states and lambda-based rapid prototyping, with a focus on timing-sensitive state transitions and zero GC allocations after setup.

## Use cases
- implement NPC AI behavior states in Unity
- manage player character states like walk, run, sneak, jump
- organize complex game logic such as weapon handling with firing, cooling, and reloading
- build hierarchical state machines to reduce duplicate code between states
- prototype game logic quickly with lambda-based states
- handle timing and synchronization sensitive state transitions
- use state machines with Unity coroutines

## When to choose
- you are building a Unity game and need to organize state-based logic like AI or character behavior
- you want a state machine with no GC allocations during state changes to avoid lag spikes
- you need hierarchical states to share logic between related states
- you want fast prototyping with lambda states and easy migration to class-based states
- you need precise control over state transition timing

## When to avoid
- you need a visual node-based state machine editor rather than a code API
- your project does not use Unity or .NET/C#
- you need behavior trees or utility AI rather than finite state machines
- you want a full-featured AI framework with pathfinding and sensing built in

## Facets
- artifact type: library
- maturity: stable
- function: game-engine, developer-tools
- domain: gaming-tools, cross-platform
- platform: game-engine, cross-platform
- tags: unity, fsm, finite-state-machine, hierarchical, csharp, gamedev, coroutines, ai-behavior, no-gc-allocations, game-development

## Member repositories
- Inspiaaa/UnityHFSM (main) score 72

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:09.429004+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:53:12.783259+00:00, confidence not recorded.
  - readme: https://github.com/Inspiaaa/UnityHFSM (fetched 2026-08-28T04:05:09.429004+00:00, sha 0f17721e332e)
- Data as of 2026-08-30T08:39:29.467469+00:00.
