A Condition answers a yes-or-no question for a transition. Use Conditions for checks such as whether a timer has elapsed, a target is in range, a variable has a particular value, or the player pressed an input.

Watch the if/else conditions tutorial on YouTube.

States organize behavior into modes, Actions perform the work for the active state, and Conditions decide whether the state machine may follow a transition to another state.

In the editor

Select a transition and add its Conditions in the Element Inspector. Conditions belong to the transition rather than to either connected state.

The transition also owns two settings that control how its Conditions are used:

  • Condition Mode combines multiple Conditions. All requires every Condition to be valid, while Any allows the transition when at least one is valid.
  • Evaluation Mode decides when State Designer checks the Conditions.

Use a GameObject Condition for most checks that work with scene objects and Unity components. Use an Entity Condition when the project needs the check to run through an ECS workflow.

Use transition and Condition menus

Right-click a transition to use these commands:

  • Copy Transition and Paste Transition copy compatible Condition and runtime settings without changing either endpoint.
  • Set Color and Reset Color change its editor-only color.
  • Route > Bezier / Straight / Orthogonal changes the drawing style.
  • Outgoing Anchor and Incoming Anchor use Auto, Top, Bottom, Left, or Right.
  • Add Waypoint, Remove Waypoint, and Clear Waypoints control manual bends.
  • Reset Layout restores routing, anchors, color, and waypoints.
  • Delete removes the transition.

Hover over a transition to inspect its Condition Mode, Evaluation Mode, and Condition summary without changing the selection. Disabled Condition rows are marked as off.

The Conditions list supports Enable/Disable, drag reordering, + to open the searchable Condition selector, and to remove the selected row. Search, Favorites, Recent, Documentation, and the Kind, Member, Scope, Returns, Requires, and Execution filters work as described on the States page, but results are limited to compatible Conditions.

Right-click a Condition row for Replace, Rename, Edit Script, Locate Script, Copy, Paste, Duplicate, or Delete. Copy, Duplicate, and Delete can use a multi-row selection; Replace and Rename require one row. Right-click blank list space to paste copied Conditions. Dragging a GameObject or Component onto a transition opens a compatible Condition selector and assigns the target automatically. Serialized list edits are unavailable in Play Mode.

Movement Conditions settings

Movement Result Comparison settings

Setting Default Description
Result Default The movement result to compare.
Expected Result MovementResult.Succeeded The expected movement result.
Comparison Type Equal The comparison operation.

Movement Result values: None, Running, Succeeded, InvalidAgent, InvalidTarget, DestinationRejected, NoWaypoints, NoCoverFound, CoverOccupied, PathInvalid, PathPartial, TimedOut, Stuck, OwnershipDenied, OwnershipLost, TraversalRequired, Cancelled.

Comparison Type values: Equal, NotEqual.

Movement Agent Arrived For Duration settings

Setting Default Description
Arrival Distance 0.25f The additional arrival tolerance.
Required Duration 0.15f The uninterrupted arrival duration.

Movement Agent Stuck For Duration settings

Setting Default Description
Required Duration 0.25f The uninterrupted stuck duration.

Movement Agent Has Path settings

Setting Default Description
Expected Value true The expected has-path value.

Movement Path Status Comparison settings

Setting Default Description
Expected Status MovementPathStatus.Complete The expected path status.

Movement Path Status values: Unknown, Pending, Complete, Partial, Invalid.

Destination Reachable settings

Setting Default Description
Destination Source GameObject The destination source.
Destination Game Object Default The destination GameObject.
Destination Position Default The destination position.

Destination Source values: GameObject, Position.

Safe Distance Reached For Duration settings

Setting Default Description
Threat Default The threat used for the distance check.
Safe Distance 10f The minimum safe distance.
Required Duration 0.25f The uninterrupted safe duration.

Traversal Requested settings

Setting Default Description
Start Default Receives the traversal start position.
End Default Receives the traversal end position.
Direction Default Receives the traversal direction.
Type Default Receives the provider-defined traversal type.

How it runs

Each Condition reports whether its rule is currently valid. The transition combines those results according to Condition Mode, then changes state only when the selected Evaluation Mode allows the check.

  • Continuous checks while the source state is active and is the default behavior.
  • On State Finished checks when the state reports that it has finished.
  • On Iteration Complete checks after the state’s Actions complete one iteration.

Conditions should remain focused on decisions. If something needs to move, animate, change a value, or otherwise affect the game world, that work belongs in an Action.

Important choices and example

Use All when every requirement must pass, such as a target being both visible and within attack range. Use Any when several different checks may allow the same transition, such as hearing a sound or seeing the target.

For a Patrol-to-Chase transition, a detection Condition decides whether a target has been found. With Continuous evaluation, the state machine can enter Chase as soon as the target is detected. With On Iteration Complete, Patrol can finish its current pass before switching.

Keeping behavior in Actions and decision-making in Conditions makes each state and transition easier to understand and debug.

Use Built-in Conditions to choose a category before searching the Condition selector. Use Transition Evaluation and Priority when several transitions can be valid at once or a graph loops unexpectedly.