UNPKG

hytopia

Version:

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

322 lines (142 loc) 4.41 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) ## PathfindingEntityController class A pathfinding entity controller built on top of [SimpleEntityController](./server.simpleentitycontroller.md)<!-- -->. **Signature:** ```typescript export default class PathfindingEntityController extends SimpleEntityController ``` **Extends:** [SimpleEntityController](./server.simpleentitycontroller.md) ## Remarks This class implements pathfinding using the A\* algorithm. Pathfinding when frequently called can cause performance issues, use it sparingly. The .pathfind() method should only need to be called once in nearly all cases when attempting to move an entity to a target coordinate. ## Constructors <table><thead><tr><th> Constructor </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [(constructor)(options)](./server.pathfindingentitycontroller._constructor_.md) </td><td> </td><td> Constructs a new instance of the `PathfindingEntityController` class </td></tr> </tbody></table> ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [debug](./server.pathfindingentitycontroller.debug.md) </td><td> `readonly` </td><td> boolean </td><td> Whether to enable debug mode or not. When debug mode is enabled, the pathfinding algorithm will log debug information to the console. Defaults to false. </td></tr> <tr><td> [maxFall](./server.pathfindingentitycontroller.maxfall.md) </td><td> `readonly` </td><td> number </td><td> The maximum fall distance the entity can fall. </td></tr> <tr><td> [maxJump](./server.pathfindingentitycontroller.maxjump.md) </td><td> `readonly` </td><td> number </td><td> The maximum jump distance the entity can jump. </td></tr> <tr><td> [maxOpenSetIterations](./server.pathfindingentitycontroller.maxopensetiterations.md) </td><td> `readonly` </td><td> number </td><td> The maximum number of open set iterations that can be processed before aborting pathfinding. Defaults to 200. </td></tr> <tr><td> [speed](./server.pathfindingentitycontroller.speed.md) </td><td> `readonly` </td><td> number </td><td> The speed of the entity. </td></tr> <tr><td> [target](./server.pathfindingentitycontroller.target.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md) \| undefined </td><td> The target coordinate to pathfind to. </td></tr> <tr><td> [verticalPenalty](./server.pathfindingentitycontroller.verticalpenalty.md) </td><td> `readonly` </td><td> number </td><td> The vertical penalty for the pathfinding algorithm. A higher value will prefer paths with less vertical movement. </td></tr> <tr><td> [waypointNextIndex](./server.pathfindingentitycontroller.waypointnextindex.md) </td><td> `readonly` </td><td> number </td><td> The index representing the next waypoint moving towards of the current set of waypoints being followed. </td></tr> <tr><td> [waypoints](./server.pathfindingentitycontroller.waypoints.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md)<!-- -->\[\] </td><td> The current waypoints being followed. </td></tr> <tr><td> [waypointTimeoutMs](./server.pathfindingentitycontroller.waypointtimeoutms.md) </td><td> `readonly` </td><td> number </td><td> The timeout in milliseconds for a waypoint to be considered reached. Defaults to 2000ms divided by the speed of the entity. </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [pathfind(target, speed, options)](./server.pathfindingentitycontroller.pathfind.md) </td><td> </td><td> Calculate a path and move to the target if a path is found. Returns true if a path is found, false if no path is found. </td></tr> </tbody></table>