Conditions
A Condition is the part of the state machine that decides whether a transition is allowed to happen. If Actions are the part that do the work, and States are the part that organize behavior into modes, then conditions are the part that answer the question: “Is it time to switch to another state yet?” That is the main job of a condition. It checks a rule and returns a yes/no result.
How Conditions Relate to States and Actions
Conditions are closely related to states and actions, but they play a different role. A State is the current behavior mode (Idle, Patrol, Attack, etc.). The Actions inside that state handle the behavior while the state is active. Conditions are attached to the transitions between states and determine whether the machine is allowed to move from one state to another.
So in practice:
- States organize behavior.
- Actions do the behavior.
- Conditions decide when a transition can happen.
This split is what keeps the graph readable. You can look at a state and understand what it does (actions), then look at the transitions and understand when it exits (conditions).
What a Condition Checks
Conditions are usually used to evaluate things like distance, timers, variable values, flags, input state, or custom game logic. They are not meant to perform the main behavior themselves. Instead, they check whether the current situation matches the rules for leaving the current state. For example, a transition from Chase to Attack might have conditions that check whether the target is in range and still valid. If the conditions are true, the transition can happen.
Conditions Do Not Replace Actions
A common mistake is putting too much logic into conditions. Conditions should stay focused on decision-making. If the goal is to make something happen in the game world, that usually belongs in an action. If the goal is to decide whether a transition should happen, that belongs in a condition. This is especially helpful when you come back later to debug behavior. It is much easier to troubleshoot a graph when “doing” and “deciding” are kept separate.
Condition Modes and Evaluation Modes
This part is important because it controls how conditions actually cause transitions. Conditions themselves return valid/invalid, but the transition decides two things:
- How multiple conditions are combined (ConditionMode)
- When the conditions are checked (EvaluationMode)
In other words, these settings are configured on the transition, not on the condition node by itself.
ConditionMode (How Multiple Conditions Are Combined)
If a transition has more than one condition, ConditionMode controls how they are combined.
- All: Every condition on the transition must be valid (AND logic).
- Any: At least one condition on the transition must be valid (OR logic).
This gives you a simple way to build stricter transitions (All) or more flexible transitions (Any) without needing to create one large custom condition.
EvaluationMode (When Conditions Are Checked)
EvaluationMode controls when the transition checks its conditions.
- Continuous: Conditions are checked continuously while the source state is active (the default behavior).
- OnStateFinished: Conditions are only checked when the state reports that it has finished.
- OnIterationComplete: Conditions are checked after the state’s actions complete one iteration.
This is a useful distinction because sometimes you want transitions to react immediately, and other times you want them to wait until a state reaches a natural stopping point.
Imagine a Patrol state with a transition to Chase. The Patrol state contains actions that move along waypoints. The transition to Chase contains conditions that check whether a target was detected. If you have multiple detection checks, ConditionMode.All would require all of them to pass, while ConditionMode.Any would allow the transition if any one of them passes.
Then EvaluationMode determines when those checks are considered. If it is set to Continuous, the transition can react as soon as the target is detected. If it is set to OnIterationComplete, the state can wait until the current patrol pass completes before switching.
New Conditions
New conditions can be created using the State Designer API. See the New GameObject Condition and the New ECS Condition page for more details.