Obstacle-aware navigation combining GridPathfinder with FollowPath. More...
| Import Statement: | import Clayground.Behavior |
NavigateTo converts world-unit destinations to grid coordinates, computes a path using A*, and feeds the resulting waypoints to FollowPath for physics-based movement. It periodically recalculates the path to handle moving targets.
Example usage:
import Clayground.Behavior RectBoxBody { id: enemy NavigateTo { world: theWorld pathfinder: levelPathfinder destXWu: player.xWu destYWu: player.yWu cellSize: 2 running: true desiredSpeed: 3 recalcInterval: 500 onArrived: console.log("Reached target!") } }
See also FollowPath, MoveTo, and GridPathfinder.
actor : var |
The entity to move (defaults to parent).
cellSize : real |
World units per grid cell (default: 1).
debug : bool |
Show debug visualization of path.
debugColor : color |
Color for debug visualization.
desiredSpeed : real |
Movement speed in world units per second (default: 2).
destXWu : real |
Destination X coordinate in world units.
destYWu : real |
Destination Y coordinate in world units.
pathfinder : GridPathfinder |
The pathfinder instance to use for computing paths (required).
recalcInterval : int |
Milliseconds between path recalculations (default: 500).
running : bool |
Whether navigation is active.
world : ClayWorld2d |
The world context (required).
arrived() |
Emitted when the actor reaches the destination.
Note: The corresponding handler is onArrived.