dev-gameplay-loop-architect

Implements a finite state machine for Unity game loops, state transitions, and win/lose conditions.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Unity-UPM-Packages/Antigravity-skills --skill dev-gameplay-loop-architect-unity-upm-packages
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dev-gameplay-loop-architect
Source: https://github.com/Unity-UPM-Packages/Antigravity-skills/tree/main/.agents/skills/dev-gameplay-loop-architect
Command: npx skills add https://github.com/Unity-UPM-Packages/Antigravity-skills --skill dev-gameplay-loop-architect-unity-upm-packages

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Game state logic scattered across MonoBehaviours and hardcoded checks like GameManager.Instance.IsPlaying make Unity projects fragile and hard to extend. This Skill provides a clean architecture for managing the full game loop — boot, menu, gameplay, pause, victory, and game over — as a testable finite state machine. ## Core Features & Use Cases - FSM-Based Game Loop: Implements IGameState and IGameStateMachine contracts with self-contained state classes handling their own entry, exit, and update logic. - Decoupled Win/Lose Conditions: Encapsulates victory and defeat checks in a dedicated IWinConditionChecker service instead of hardcoding them into gameplay systems. - Manual DI Bootstrapping: Wires up all states and services in a GameBootstrapper without any framework, with a documented migration path to VContainer. - Use Case: When building a Unity game where pause menus, scene loading, and session data must react to state changes, use this Skill to architect the GameStateMachine, subscribe UI views to OnStateChanged, and reset SessionData on each new session. ## Quick Start Ask the AI to design the core game loop state machine for your Unity project with states for boot, main menu, gameplay, pause, victory, and game over.

Frequently Asked Questions about dev-gameplay-loop-architect

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

FAQPage Schema
How do I implement a game state machine in Unity?▼

Define an IGameState interface with OnEnter, OnExit, and OnUpdate methods, then create a GameStateMachine class that holds a dictionary of states and transitions between them via a generic Enter<TState>() method. Each state is a plain C# class receiving dependencies through its constructor.

How to handle pause and resume in Unity without a GameManager singleton?▼

Create dedicated GameplayState and PausedState classes that subscribe to an IInputProvider pause event. PausedState sets Time.timeScale to 0 on entry and restores it on exit, keeping pause logic out of any global singleton.

Where should win and lose conditions be checked in a Unity game?▼

Win and lose conditions belong in a dedicated IWinConditionChecker service, never hardcoded into PlayerController or EnemyManager. The checker exposes OnWinConditionMet and OnLoseConditionMet events that the GameplayState subscribes to for state transitions.

Can this state machine work with VContainer or other DI frameworks?▼

Yes, the manual DI bootstrapper maps directly to VContainer registration. Each new XxxState(...) line becomes a builder.Register<XxxState>() call, and the state classes themselves require no changes during migration.

How should Unity UI react to game state changes?▼

UI views should subscribe to the IGameStateMachine.OnStateChanged event via a Construct() injection method and toggle visibility based on the received GameStateType. Views must never poll the state machine or call game logic directly.