PathFinding. PathFinderNode

A single grid cell tracked by the pathfinder. Allocated once per cell at PathFinder construction; reset (not reallocated) at the start of every findPath call.

Constructor

new PathFinderNode(x, y)

Parameters:
NameTypeDescription
xnumber

Tile x

ynumber

Tile y

Members

cost

Properties
TypeDescription
number

Extra cost added to A* G-score for stepping on this cell

f

Properties
TypeDescription
number

A* F-score: G + heuristic

g

Properties
TypeDescription
number

A* G-score: actual cost from start to this node

h

Properties
TypeDescription
number

A* heuristic: the estimated cost left to the goal, breaks ties between equal F

heapIndex

Properties
TypeDescription
number

Where it is in the A* open list's heap, while open

isClosed

Properties
TypeDescription
boolean

In the A* closed list

isOpen

Properties
TypeDescription
boolean

In the A* open list

parent :PathFinderNode|null

Type:
  • PathFinderNode | null
Properties
TypeDescription
PathFinderNode | null

Parent for path reconstruction

pos

Properties
TypeDescription
Vector2

Tile coords (integer)

posWorld

Properties
TypeDescription
Vector2

World-space center of this tile (set by buildNodeData)

walkable

Properties
TypeDescription
boolean

True if this cell is passable (set by buildNodeData)

Methods

isClear()

True if walkable and not blocked by cost.

reset()

Reset per-search state and walkability (called by buildNodeData).

resetSearch()

Clear what a search left on this node, keeping walkable and cost