Reference Verse compiles

A state machine is a thing that's always in exactly ONE of a few named states an

Updated Examples verified on the live UEFN compiler

An enemy is ALWAYS in exactly one state — and switches on events.

guard_state := enum{Idle, Patrol, Chase}
enemy_ai := class(creative_device):
    OnBegin<override>()<suspends>:void =
        Current : guard_state = guard_state.Patrol
        case (Current):
            guard_state.Idle => Print("standing still")
            guard_state.Patrol => Print("walking route")
            guard_state.Chase => Print("chasing player!")

Takeaway — One state at a time + events to switch = a state machine.

Build your own lesson with what_is_a_state_machine

Generate a personalized, step-by-step lesson plan built around this object — grounded in this exact reference and our compile-verified knowledge base.

Build a lesson →