UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

108 lines (51 loc) 2.46 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [PathfindingEntityController](./server.pathfindingentitycontroller.md) &gt; [pathfind](./server.pathfindingentitycontroller.pathfind.md) ## PathfindingEntityController.pathfind() method Calculates a path and moves to the target if a path is found. Use for: one-shot navigation to a destination. Do NOT use for: high-frequency replanning; it is synchronous. **Signature:** ```typescript pathfind(target: Vector3Like, speed: number, options?: PathfindingOptions): boolean; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> target </td><td> [Vector3Like](./server.vector3like.md) </td><td> The target coordinate to pathfind to. </td></tr> <tr><td> speed </td><td> number </td><td> The speed of the entity (blocks per second). </td></tr> <tr><td> options </td><td> [PathfindingOptions](./server.pathfindingoptions.md) </td><td> _(Optional)_ The pathfinding options. </td></tr> </tbody></table> **Returns:** boolean True if a path was found, false otherwise. \*\*Requires:\*\* The controller must be attached to a spawned entity in a world. \*\*Side effects:\*\* Starts movement and facing if a path is found. \*\*Category:\*\* Controllers ## Remarks \*\*Synchronous return:\*\* Path calculation happens synchronously. Returns `true` if a path was found, `false` if no path exists or calculation was aborted. \*\*Auto-starts movement:\*\* If a path is found, movement begins immediately using the inherited `move()`<!-- -->, `face()`<!-- -->, and `jump()` methods from `SimpleEntityController`<!-- -->. \*\*Auto-facing (-Z forward):\*\* Automatically calls `face()` for each waypoint, orienting the entity's -Z axis toward the next waypoint. Models must be authored with their front facing -Z. \*\*A\* algorithm:\*\* Uses A\* pathfinding with configurable `maxJump`<!-- -->, `maxFall`<!-- -->, and `verticalPenalty`<!-- -->. Path calculation is capped by `maxOpenSetIterations` (default 200) to prevent blocking. \*\*Waypoint progression:\*\* Entity moves through calculated waypoints sequentially. Each waypoint has a timeout (`waypointTimeoutMs`<!-- -->) after which it's skipped if not reached.