Runtime Targets and State Patterns
Bind movement inputs and results to Graph variables when perception, commands, or another gameplay system must share them. Keep the actor controlled by the Action separate from the target it follows or avoids.
Moving targets and replacement targets
Seek reads its GameObject or position input during updates and replans within its configured interval and displacement thresholds. Move To Cover reads its threat input as it revalidates cover.
Follow, Flee, Pursue, and Evade resolve their target Transform when the Action starts. They track that object’s motion, but replacing the GameObject variable does not rebind the cached Transform during the same run. Transition out and re-enter the Action state when changing to a different target object.
Changing a variable does not itself select another state. Use a Continuous transition for target loss, target replacement, danger, or an incoming command. Re-entry starts fresh Action state; do not assume it resumes a previous patrol index or wander destination. Pause/resume is the workflow for temporarily suspending the current run.
Change a target from code
Create a Graph variable named MovementTarget with type GameObject and bind Seek’s Destination GameObject to it. This component updates the same variable after the state machine has initialized:
using Opsive.GraphDesigner.Runtime.Variables;
using Opsive.StateDesigner.Runtime;
using UnityEngine;
/// <summary>
/// Supplies a destination object to a State Designer graph.
/// </summary>
public class MovementTargetDriver : MonoBehaviour
{
[Tooltip("The initialized state machine containing MovementTarget.")]
[SerializeField] private StateMachine m_StateMachine;
private SharedVariable<GameObject> m_Target;
/// <summary>
/// Resolves the Graph-scope destination variable.
/// </summary>
private void Start()
{
m_Target = m_StateMachine.GetVariable<GameObject>("MovementTarget");
}
/// <summary>
/// Assigns the object that Seek should track.
/// </summary>
/// <param name="target">The new destination object.</param>
public void SetTarget(GameObject target)
{
m_Target.Value = target;
}
}
Call SetTarget after Start. The name, capitalization, type, and Graph scope must match the authored variable. For other scopes, use Accessing Variables. For cached-target Actions, also trigger a state change that restarts the Action.
Patrol and investigate
Create Patrol, Investigate, and Search Action States. Patrol uses a waypoint array with Required Cycles: 0. A perception or gameplay system writes a remembered world-space position and permits a Continuous transition into Investigate.
Investigate uses Seek with Destination Source: Position. Its Succeeded result permits Search; a path failure permits a recovery or return-to-patrol route. Search can wait or turn using main-product Actions before returning to Patrol. A new Patrol run starts a fresh route rather than automatically resuming the previous waypoint.

The example’s ApplicationInvestigateCommand reads the application’s InvestigateRequested Graph variable on a Continuous transition. Investigate reads LastKnownPosition and writes MoveResult. These application Conditions are documentation examples, not additional Movement Pack Conditions. Search and Recover are Idle placeholders for the application’s search, recovery, and return decisions.
Chase and hold distance
Use Pursue in Chase while the target is far away. A distance Condition can interrupt Chase and enter Hold Range, where Follow uses Continuous completion and a minimum/maximum distance band. Follow’s Face Target can supply facing while in this state.
Transitions into Attack should check gameplay readiness and range. Put target-loss and urgent escape decisions before broad fallback routes. When switching targets, leave and re-enter the cached-target Action as described above.
Escape and recover
Use Flee for current-position threats or Evade for predicted threats. Their own success rules already require a sustained safe interval. An outgoing core Condition or ConditionDelegate that checks for Succeeded can enter Recover, while path rejection or stuck movement can enter Find Alternate Route.
A core distance/timing Condition or application check can make a separate current-distance decision. That decision does not reproduce Evade’s prediction-aware safety test; choose the test that matches the intended behavior.
Find cover and engage
Run Move To Cover with Arrival, read Required Stance, and apply posture through the character controller. Use Maintain when protection must be revalidated and recovered continuously; a Continuous transition can leave it for attack or retreat.
After an Arrival Action finishes, its cover outputs describe the last selection. The Action no longer maintains safety or renews its reservation indefinitely. Validate ongoing protection through the application or return to a Maintain cover state when that matters to engagement.
One movement owner
All eight Actions acquire exclusive ownership through Movement Agent. A second movement Action reports Ownership Denied rather than silently replacing the first route. Run one navigation Action per actor.
When an external controller or traversal integration moves the same actor, coordinate its provider explicitly. Avoid competing root motion, Rigidbody, Character Controller, and navigation writes. Traversal Integration describes the off-mesh handoff API.