Use this graph when low health should interrupt several ordinary states through one shared, high-priority route.

In the editor

  1. Create a float Shared Variable named Health.
  2. Add an Any state above the ordinary Idle, Patrol, Chase, and Attack flow.
  3. Add a Flee Action State and connect Any to Flee.
  4. On the Any-to-Flee transition, add Float Comparison, compare Health with the entry threshold, and use Less Than Or Equal To. A value such as 25 is a useful starting example.
  5. Set the transition to Continuous evaluation and leave Can Reenter disabled.
  6. Connect Flee to a deliberate recovery state, such as Patrol. Add another Float Comparison that requires Health to be greater than or equal to a higher recovery threshold, such as 40.

The Any state routes low health from the normal behavior flow into Flee.

Flee should contain a movement or defensive Action that remains Running until the recovery transition becomes valid.

How it runs

State Designer evaluates the Any-to-Flee transition while any ordinary state is active. When Health reaches the entry threshold, the current state ends and Flee starts. Any itself never becomes the active behavior state.

The higher recovery threshold prevents the graph from rapidly switching near one value. At Health 30, for example, the agent remains in Flee because it has not recovered to 40. Once the recovery transition succeeds, Patrol becomes active.

Key choices

  • Put the most important Any transition first when the graph has several global interrupts.
  • Leave Can Reenter disabled for a persistent low-health condition so Flee is not restarted every evaluation.
  • Use different entry and recovery thresholds. A single shared boundary can cause visible state chatter when health regeneration and damage alternate near that value.
  • Choose the return state explicitly. Any does not remember and restore the state that it interrupted.

Verify in Play Mode

Change Health while Patrol, Chase, and Attack are active. Each state should enter the same Flee state at or below the entry threshold. Confirm that Flee does not restart while already active and does not exit until Health reaches the recovery threshold.