Class NavigationWaypoint
One node in a branching navigation route managed by NavigationWaypointManager. Holds outgoing links to its possible successor waypoints and fires an activation event when the player reaches it, which the manager uses to advance the route to this node's successors.
public class NavigationWaypoint : MonoBehaviour
Inheritance
Examples
Trigger arrival from a physics trigger zone on the same GameObject:
public class WaypointTriggerZone : MonoBehaviour
{
private NavigationWaypoint _waypoint;
private void Awake() => _waypoint = GetComponent();
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
_waypoint.StartEvent();
}
}
Subscribe to arrival from any component that needs to react without holding a reference to NavigationWaypointManager:
private void OnEnable() => waypoint.subscribableAction += OnArrived;
private void OnDisable() => waypoint.subscribableAction -= OnArrived;
private void OnArrived(NavigationWaypoint reached)
{
Debug.Log($"Player reached {reached.name}");
}
Remarks
The navigation route is a directed branching structure: each waypoint's NextWaypoints array defines which waypoints become the next available targets once this one is triggered. NavigationWaypointManager traverses that structure by replacing its active list with the triggered node's successor set — so a single waypoint can fork the route into multiple choices simply by listing more than one successor in the Inspector.
Arrival at this waypoint must be signalled by one of the following:
- An EventTrigger wired to call StartEvent in the Inspector.
- A runtime call to StartEvent from a trigger-zone component.
Either route invokes subscribableAction, notifying all subscribers — including NavigationWaypointManager — that this node has been reached.
Fields
subscribableAction
Actions that are invoked when the waypoint is interacted with.
public Action<NavigationWaypoint> subscribableAction
Field Value
Properties
NextWaypoints
Gets the array of connected next waypoints.
public NavigationWaypoint[] NextWaypoints { get; }