A production-oriented Hierarchical Finite State Machine (HFSM) for Unity — featuring nested/parallel states, state history, flexible transitions, async flows, and a live Editor debugger.ApexionGame HFSM: a hierarchical state machine for Unity 6, with a debugger that explains every decision.Enemy AI, boss phases, UI flows and game states all grow into tangled if chains sooner or later. When one misbehaves, the hard question is rarely what the AI did. It's why.ApexionGame HFSM gives you two things:A code-first hierarchical state machine that scales from a two-state door to a boss with parallel behaviours.Live debugging tools that tell you, in plain language, why a machine moved: "Moved here from Chase because InMeleeRange became true (DistanceToPlayer = 4.1 now)."You declare machines in C# with a typed builder. There is no visual graph editor and no lock-in. Full C# source is included.Who it's forGameplay programmers building enemy, boss, NPC or companion AITeams who want state logic that is readable, testable and diff-friendly in version controlAnyone who has lost an afternoon asking "why did it switch states?"Build complex behaviour from simple partsNested composite states, so shared behaviour is written once at the parentParallel regions: locomotion, attacks and guarding run side by side in one machineShallow and deep history, to resume a state tree where it left offGuard, trigger, timer and request transitions, with priorities and minimum durationsNamed and composed guards (Named, All, Any, Unless) that stay readable in the debuggerAsync enter/exit for animations, fades and scene loads, using UnityEngine.Awaitable or optionally UniTaskDeclaration modules: write a Combat or Locomotion fragment once and reuse it across several machinesSnapshots: save and restore a machine's state safely. A save from an outdated machine shape is rejected, not restored wrongly.See what your AI is thinkingMachine Inspector Probe: add one component to any GameObject and its Inspector shows, in Play Mode:the active path (Root › Combat › Attack · 0.7s)the reason for the last moveevery possible next move, with progress bars for guards that compare numberswatched context values and historyHFSM Debugger window: a live graph with animated transitions and the decision the last tick actually made, recorded rather than re-evaluated. It includes a minimap, search-free navigation, edge filters and semantic zoom, and it's built for graphs of 150+ nodes.A scene ring that marks the selected actor in the Scene and Game viewsBuilt for production0 B managed allocation on the steady-state tick, asserted by the test suitePooled instances with an optional cap, plus a shared runner for many agentsProfiler markers for Tick, Resolve and TransitionDebug code is stripped from release buildsLearn by exampleThe HFSM Playground sample is a ready-to-run scene with five live machines: four enemy archetypes (Guard, Coward, Turret, Scout) and a flagship Boss with four parallel regions. Stats live on prefab components, so balancing is an Inspector edit, not a recompile.In the boxFull C# source: runtime and Editor assembliesHFSM Playground samplePDF User Manual with annotated screenshots, plus 8 guides: Getting Started, Recipes, Concepts, Debugger, Snapshot and Modules, Performance, Troubleshooting and the indexSupport and communityDiscord: Ask questions, share your machines and request features.Check the Troubleshooting guide first for common compile and build errors.RequirementsUnity 6000.3.20f1 or newer (6000.3 stream)com.unity.collections and com.unity.mathematics, added automatically on importScope: this is a code-first state machine with a read-only live debugger. It has no visual graph authoring.Version CompatibilityUnity 6000.3.20f1 or newer (6000.3 stream).Platform SupportAny platform Unity supports — pure C#, no native plugins, no platform-specific code.Dependencies (Not included — must be added separately, see documentation)Unity Collections 2.6.8 — required. Resolves automatically from Unity's registry.Unity Mathematics 1.3.3 — required. Resolves automatically from Unity's registry.UniTask 2.5.11 — optional. Only needed if you prefer it over Unity's built-in Awaitable for async transitions.What's IncludedRuntime assembly (ApexionGame.HFSM):The state machine core — builder API, transitions, history, parallel regions, async flows, pooling, the shared runner.Editor assembly:[A live runtime debugger window (pan/zoom graph, active-leaf/transition animation, guard inspector, scene marker).Authoring assembly: The MachineGraphAsset data model and typed MachineGraphBindings for the visual editor.Test assembly: The full EditMode test suite (155 tests) used to develop this package.Sample: "HFSM Playground" — a self-running Play Mode scene with 5 live machine instances (4 interchangeable enemy archetypes + 1 flagship Boss using parallel regions).Known LimitationsThe UI Toolkit visual graph editor is implemented but gated behind a "coming soon" notice in this version. All machines must currently be authored through the code-first builder API (fully documented, used throughout the included sample).DocumentationFull README covers installation, quick start, async transitions, performance characteristics, and the debug scripting defines (APEXION_HFSM_DEBUG, DISABLE_APEXION_CHECKS).




