Constructor
new Navigator(actor, worldopt)
Creates navigation for an actor without owning its update lifecycle.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
actor |
Object | Object with x, y and optional radius in tile units. | |
world |
rune.raycast.World |
<optional> |
World; defaults to the actor's parent. |
- Source:
Members
actor :Object
Actor moved by this navigator.
Type:
- Object
- Source:
(readonly) arrived :boolean
Whether the last active update reached stopDistance when following or
safeDistance when fleeing. Always false for wandering, stopped, paused or
unbound navigation. Moving targets are evaluated again on the next update.
Type:
- boolean
- Source:
(readonly) blocked :boolean
Whether a route is unavailable or movement cannot continue. Remains true
while retrying a failed route. False on arrival, pause, stop or mode change;
ordinary route refreshes do not count as blocked. Reports the last update,
not a permanent failure: doors and moving targets may restore progress.
Type:
- boolean
- Source:
(readonly) direction :rune.geom.Point
Last movement direction. Reused Point; callers should treat it as read-only.
Assign it to Billboard.direction to connect navigation and directional frames.
Type:
- Source:
enabled :boolean
Whether navigation advances. Disabling preserves the current route.
Type:
- boolean
- Source:
(readonly) moving :boolean
Whether navigation moved the actor during its last update.
Type:
- boolean
- Source:
safeDistance :number
Distance from the threat at which fleeing stops, in tiles.
Type:
- number
- Source:
searchDistance :number
Maximum route length explored when choosing a flee destination, in cells.
Type:
- number
- Source:
speed :number
Travel speed in tiles per second.
Type:
- number
- Source:
stopDistance :number
Distance to keep from the target, in tiles.
Type:
- number
- Source:
(nullable) target :Object
Point or actor to follow, or the threat selected by flee(). Null disables
target-based navigation; use follow(), flee() or wander() to select behavior.
Type:
- Object
- Source:
(nullable) world :rune.raycast.World
Explicit world, or null to use the actor parent.
Type:
- Source:
Methods
dispose() → {undefined}
Releases references without disposing the actor, target or world.
- Source:
Returns:
- Type
- undefined
flee(target) → {undefined}
Flees from a point or actor until safeDistance is reached. A bounded search
selects a reachable safer cell, allowing temporary travel toward the threat
to escape dead ends. Navigation resumes if the threat approaches again.
No damage, animation, perception or threat selection is applied.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
Object | Threat with x and y in tiles. |
- Source:
Returns:
- Type
- undefined
follow(target) → {undefined}
Follows a point or actor, replacing any wandering or fleeing behavior.
Assigning target directly remains supported for ordinary following.
Parameters:
| Name | Type | Description |
|---|---|---|
target |
Object | Point or actor with x and y in tiles. |
- Source:
Returns:
- Type
- undefined
stop() → {undefined}
Clears the target and route, retaining the last facing direction.
Use enabled=false instead to pause and later resume the current behavior.
- Source:
Returns:
- Type
- undefined
update(step) → {undefined}
Advances navigation using World movement and pathfinding. Blocked routes are
retried at most twice per second. Routes refresh at cell centers to avoid
cutting wall corners. No input, animation or combat behavior is applied.
Parameters:
| Name | Type | Description |
|---|---|---|
step |
number | Elapsed time in milliseconds. |
- Source:
Throws:
-
If timing or navigation settings are invalid.
- Type
- RangeError
Returns:
- Type
- undefined
wander() → {undefined}
Starts continuous random wandering through neighboring walkable cells.
Avoids turning back except at dead ends. Has no built-in idle pauses.
Setting target switches back to following; stop() disables navigation.
- Source:
Returns:
- Type
- undefined