Back to search
PatternGold tierArchitecture

State machine pattern using enum variable and switch

Updated 6mo ago
UE 5.3UE 5.4UE 5.5UE 5.6UE 5.7#state#machine#enum#switch#pattern#fsm

Reference

Variables: CurrentState (your EState enum: Idle, Patrol, Chase, Attack, Dead).

EventTick or custom Update event → Switch on EState(CurrentState) → Idle: [idle logic] → Patrol: [patrol logic] → Chase: [chase logic] etc.

State transitions via custom events: OnEnemySpotted → SetVariable(CurrentState=EState::Chase). OnEnemyLost → SetVariable(CurrentState=EState::Patrol). OnDamaged → Branch(Health<=0) → True: SetVariable(CurrentState=EState::Dead).

Key: Switch On Enum node — connect enum variable to the input, each value gets an exec output pin.