Skip to content

Latest commit

 

History

History
287 lines (127 loc) · 3.94 KB

File metadata and controls

287 lines (127 loc) · 3.94 KB

Home > server > PathfindingEntityController

PathfindingEntityController class

A pathfinding entity controller built on top of SimpleEntityController.

Signature:

export default class PathfindingEntityController extends SimpleEntityController 

Extends: SimpleEntityController

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.

Properties

Property

Modifiers

Type

Description

debug

readonly

boolean

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.

maxFall

readonly

number

The maximum fall distance the entity can fall.

maxJump

readonly

number

The maximum jump distance the entity can jump.

maxOpenSetIterations

readonly

number

The maximum number of open set iterations that can be processed before aborting pathfinding. Defaults to 200.

speed

readonly

number

The speed of the entity.

target

readonly

Vector3Like | undefined

The target coordinate to pathfind to.

verticalPenalty

readonly

number

The vertical penalty for the pathfinding algorithm. A higher value will prefer paths with less vertical movement.

waypointNextIndex

readonly

number

The index representing the next waypoint moving towards of the current set of waypoints being followed.

waypoints

readonly

Vector3Like[]

The current waypoints being followed.

waypointTimeoutMs

readonly

number

The timeout in milliseconds for a waypoint to be considered reached. Defaults to 2000ms divided by the speed of the entity.

Methods

Method

Modifiers

Description

pathfind(target, speed, options)

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.