Methods
-
<static> getBoundsPathfollowing(entity, x, y, width, height, target, zeroGrav, bounds) → {Object}
-
Calculates following position and bounds for an entity to align with while following a path.
Parameters:Name Type Argument Default Description entityig.EntityExtended entity to find position for. xNumber x position of entity yNumber y position of entity widthNumber width of entity heightNumber height of entity targetig.pathfinding.Node | Vector2 | Object target node or position zeroGravBoolean <optional>
false whether to treat as if has no gravity boundsObject <optional>
bounding object - Source:
{ Object } bounds within bounds of entity to start and align while following a path. -
<static> getDiagonalNeighbors(node) → {Array}
-
Get only the diagonal walkable neighbors of the given node, excluding direct.
Parameters:Name Type Description nodeig.pathfinding.Node node to get neighbors for - Source:
{ Array } neighbors of nodeExample// neighbors are precalculated on rebuild // so this is usually a bad idea: var myNeighbors = ig.pathfinding.getNeighbors( myNode ); // this is a better idea var myNeighbors = myNode.neighbors; -
<static> getDirectNeighbors(node) → {Array}
-
Get only the direct walkable neighbors of the given node, excluding diagonals.
Parameters:Name Type Description nodeig.pathfinding.Node node to get neighbors for - Source:
{ Array } neighbors of nodeExample// neighbors are precalculated on rebuild // so this is usually a bad idea: var myNeighbors = ig.pathfinding.getNeighbors( myNode ); // this is a better idea var myNeighbors = myNode.neighbors; -
<static> getEntityNeighborPositionX(x, width, dirX)
-
Calculates x position of node next to entity.
Parameters:Name Type Description xNumber x position of entity widthNumber width of entity dirXNumber x direction - Source:
-
<static> getEntityNeighborPositionY(y, height, dirY, zeroGrav)
-
Calculates y position of node next to entity.
Parameters:Name Type Argument Default Description yNumber y position of entity heightNumber height of entity dirYNumber y direction zeroGravBoolean <optional>
false whether to treat as if has no gravity - Source:
-
<static> getEntityOnSmoothSlope(entity, dirX, dirY) → {boolean}
-
Calculates whether entity (with gravity) may be moving along a smooth slope. This is useful for knowing if the entity can just move or if it needs to jump.
Parameters:Name Type Argument Default Description entityig.EntityExtended entity dirXNumber x direction of movement, where < 0 is left dirYNumber <optional>
both y direction of movement, where < 0 is up - Source:
{ boolean } true if moving along a smooth slope -
<static> getGridNode(gridX, gridY) → {ig.pathfinding.Node}
-
Get a node in the pathfinding grid using grid coordinates.
Parameters:Name Type Description gridXNumber x index of node. gridYNumber y index of node. - Source:
{ ig.pathfinding.Node } node at index. -
<static> getGridWalkableNode(x, y, gridOffsetX, gridOffsetY, avoidEntities, entityPathing) → {ig.pathfinding.Node}
-
Get a walkable node in the pathfinding grid using grid coordinates.
Parameters:Name Type Argument Default Description xNumber x index to start from. yNumber y index to start from. gridOffsetXNumber <optional>
0 number of nodes to offset on x. gridOffsetYNumber <optional>
0 number of nodes to offset on y. avoidEntitiesBoolean <optional>
false whether to take into account entities that may collide, requires entityPathing. entityPathingig.EntityExtended <optional>
entity that will be walking to node, only required when avoiding entities. - Source:
{ ig.pathfinding.Node } walkable node at index. -
<static> getNeighbors(node) → {Array}
-
Get all walkable neighbors of the given node.
Parameters:Name Type Description nodeig.pathfinding.Node node to get neighbors for - Source:
{ Array } neighbors of nodeExample// neighbors are precalculated on rebuild // so this is usually a bad idea: var myNeighbors = ig.pathfinding.getNeighbors( myNode ); // this is a better idea var myNeighbors = myNode.neighbors; -
<static> getNode(x, y, gridOffsetX, gridOffsetY) → {ig.pathfinding.Node}
-
Get a node in the pathfinding grid using world coordinates.
Parameters:Name Type Argument Default Description xNumber x location in world. yNumber y location in world. gridOffsetXNumber <optional>
0 number of nodes to offset on x. gridOffsetYNumber <optional>
0 number of nodes to offset on y. - Source:
{ ig.pathfinding.Node } node at point. -
<static> getPathAwayFrom(fromX, fromY, awayFromX, awayFromY, avoidEntities, searchDistance, entityPathing, heuristicType) → {Array}
-
Get a path that goes furthest away from a point.
Parameters:Name Type Argument Default Description fromXNumber x position to start from fromYNumber y position to start from awayFromXNumber x position to path away from awayFromYNumber y position to path away from avoidEntitiesBoolean <optional>
false whether to try to avoid entities searchDistanceNumber <optional>
ig.pathfinding.AWAY_FROM_DISTANCE distance to flee entityPathingig.EntityExtended <optional>
entity to find path for heuristicTypeString <optional>
Type of heuristic function to use - Source:
{ Array } path as a list of points with x and y properties. -
<static> getPathAwayFromEntity(entityPathing, entityTarget, avoidEntities, searchDistance, heuristicType) → {Array}
-
Get the path that goes furthest away from a target entity for another entity.
Parameters:Name Type Argument Default Description entityPathingig.EntityExtended entity to find path for entityTargetig.EntityExtended entity to find path away from avoidEntitiesBoolean <optional>
false whether to try to avoid entities searchDistanceNumber <optional>
ig.pathfinding.AWAY_FROM_DISTANCE distance to flee heuristicTypeString <optional>
Type of heuristic function to use - Source:
{ Array } path as a list of points with x and y properties. -
<static> getPathAwayFromPoint(entityPathing, awayFromX, awayFromY, avoidEntities, searchDistance, heuristicType) → {Array}
-
Get a path that goes furthest away from a point for an entity.
Parameters:Name Type Argument Default Description entityPathingig.EntityExtended entity to find path for awayFromXNumber x position to path away from awayFromYNumber y position to path away from avoidEntitiesBoolean <optional>
false whether to try to avoid entities searchDistanceNumber <optional>
ig.pathfinding.AWAY_FROM_DISTANCE distance to flee heuristicTypeString <optional>
Type of heuristic function to use - Source:
{ Array } path as a list of points with x and y properties. -
<static> getPathTo(fromX, fromY, targetX, targetY, avoidEntities, searchDistance, entityPathing, entityTarget, heuristicType) → {Array}
-
Get the path to target point.
Parameters:Name Type Argument Default Description fromXNumber x position to start from fromYNumber y position to start from targetXNumber x position to path to targetYNumber y position to path to avoidEntitiesBoolean <optional>
false whether to try to avoid entities searchDistanceNumber <optional>
infinity maximum positive distance to search entityPathingig.EntityExtended <optional>
entity to find path for entityTargetig.EntityExtended <optional>
entity to find path to heuristicTypeString <optional>
Type of heuristic function to use - Source:
{ Array } path as a list of points with x and y properties. -
<static> getPathToEntity(entityPathing, entityTarget, avoidEntities, searchDistance, heuristicType) → {Array}
-
Get the path to target entity from another entity.
Parameters:Name Type Argument Default Description entityPathingig.EntityExtended entity to find path for entityTargetig.EntityExtended entity to find path to avoidEntitiesBoolean <optional>
false whether to try to avoid entities searchDistanceNumber <optional>
infinity maximum positive distance to search heuristicTypeString <optional>
Type of heuristic function to use - Source:
{ Array } path as a list of points with x and y properties. -
<static> getPathToPoint(entityPathing, targetX, targetY, avoidEntities, searchDistance, entityTarget, heuristicType) → {Array}
-
Get the path to a point from an entity.
Parameters:Name Type Argument Default Description entityPathingig.EntityExtended entity to find path for targetXNumber x position to path to targetYNumber y position to path to avoidEntitiesBoolean <optional>
false whether to try to avoid entities searchDistanceNumber <optional>
infinity maximum positive distance to search entityTargetig.EntityExtended <optional>
entity to find path to heuristicTypeString <optional>
Type of heuristic function to use - Source:
{ Array } path as a list of points with x and y properties. -
<static> getPositionPathfindingEntities(entity, target, positions) → {Object}
-
Calculates the positions and bounds for entities to align for pathfinding.
Parameters:Name Type Argument Description entityig.EntityExtended entity to find position for. targetig.EntityExtended target entity. positionsObject <optional>
positions object with from and target vectors - Source:
{ Object } positions within bounds of entity to start and align for pathfinding. -
<static> getPositionPathfindingPoint(entity, targetX, targetY, position) → {Object}
-
Calculates the positions and bounds for entity to align for pathfinding.
Parameters:Name Type Argument Description entityig.EntityExtended entity to find position for. targetXNumber target x targetYNumber target y positionObject <optional>
position object - Source:
{ Object } position within bounds of entity to start and align for pathfinding. -
<static> getSlopeDirectionY(entity, dirX) → {Number}
-
Calculates the y direction of a slope an entity (with gravity) is moving on, based on the x direction of movement. This is useful for knowing if the entity should move down or up in addition to sideways.
Parameters:Name Type Description entityig.EntityExtended entity dirXNumber x direction of movement, where < 0 is left - Source:
{ Number } direction y, where -1 is up -
<static> getWalkableNode(x, y, gridOffsetX, gridOffsetY, avoidEntities, entityPathing) → {ig.pathfinding.Node}
-
Get a walkable node in the pathfinding grid using world coordinates.
Parameters:Name Type Argument Default Description xNumber x location in world to start from. yNumber y location in world to start from. gridOffsetXNumber <optional>
0 number of nodes to offset on x. gridOffsetYNumber <optional>
0 number of nodes to offset on y. avoidEntitiesBoolean <optional>
false whether to take into account entities that may collide, requires entityPathing. entityPathingig.EntityExtended <optional>
entity that will be walking to node, only required when avoiding entities. - Source:
{ ig.pathfinding.Node } walkable node at point. -
<static> getWalkableNodeChain(x, y, dirX, dirY, numNodes, avoidEntities, entityPathing, nodes) → {Array}
-
Get a chain of walkable nodes in the pathfinding grid using world coordinates in a direction.
Parameters:Name Type Argument Default Description xNumber x location in world to start from. yNumber y location in world to start from. dirXNumber x direction, between -1 and 1, to find chain. dirYNumber y direction, between -1 and 1, to find chain. numNodesNumber <optional>
2 maximum number of nodes to find. avoidEntitiesBoolean <optional>
false whether to take into account entities that may collide, requires entityPathing. entityPathingig.EntityExtended <optional>
entity that will be walking to node, only required when avoiding entities. nodesArray <optional>
array to add nodes to - Source:
{ Array } walkable nodes in direction. -
<static> isDirectionWalkable(node, dirX, dirY, nodeFrom)
-
Get if a node is walkable from a direction, accounting for one way and, when the node from is passed, diagonal movement.
Parameters:Name Type Argument Description nodeig.pathfinding.Node node to check dirXNumber direction of travel on x dirYNumber direction of travel on y nodeFromig.pathfinding.Node <optional>
node traveling from - Source:
-
<static> isGridPointInGrid(gridX, gridY) → {Boolean}
-
Check if node is within the bounds of pathfinding grid using grid coordinates.
Parameters:Name Type Description gridXNumber x index of node. gridYNumber y index of node. - Source:
{ Boolean } whether node is within grid. -
<static> isGridWalkable(x, y, gridOffsetX, gridOffsetY, avoidEntities, entityPathing) → {Boolean}
-
Check if a grid location is walkable using grid coordinates.
Parameters:Name Type Argument Default Description xNumber x index to start from. yNumber y index to start from. gridOffsetXNumber <optional>
0 number of nodes to offset on x. gridOffsetYNumber <optional>
0 number of nodes to offset on y. avoidEntitiesBoolean <optional>
false whether to take into account entities that may collide, requires entityPathing. entityPathingig.EntityExtended <optional>
entity that will be walking to node, only required when avoiding entities. - Source:
{ Boolean } whether node is walkable. -
<static> isPointInGrid(x, y, gridOffsetX, gridOffsetY) → {Boolean}
-
Check if node is within the bounds of pathfinding grid using world coordinates.
Parameters:Name Type Argument Default Description xNumber x location in world. yNumber y location in world. gridOffsetXNumber <optional>
0 number of nodes to offset on x. gridOffsetYNumber <optional>
0 number of nodes to offset on y. - Source:
{ Boolean } whether node is within grid. -
<static> isWalkable(x, y, gridOffsetX, gridOffsetY, avoidEntities, entityPathing) → {Boolean}
-
Check if a world location is walkable using world coordinates.
Parameters:Name Type Argument Default Description xNumber x location in world to start from. yNumber y location in world to start from. gridOffsetXNumber <optional>
0 number of nodes to offset on x. gridOffsetYNumber <optional>
0 number of nodes to offset on y. avoidEntitiesBoolean <optional>
false whether to take into account entities that may collide, requires entityPathing. entityPathingig.EntityExtended <optional>
entity that will be walking to node, only required when avoiding entities. - Source:
{ Boolean } whether node is walkable. -
<static> nodeHasCollidingEntities(node, nodeFrom, entityPathing, entityTarget) → {Boolean}
-
Checks a node to see if there are any entities that would collide with pathing entity.
Parameters:Name Type Argument Description nodeig.pathfinding.Node node to get weight for nodeFromig.pathfinding.Node node moving from entityPathingig.EntityExtended entity to find path for entityTargetig.EntityExtended <optional>
entity to find path to - Source:
{ Boolean } whether node has a colliding entity -
<static> rebuild(collisionMap, pathfindingMap)
-
Rebuild pathfinding.
Parameters:
- this is called automatically by ig.GameExtended#buildLevel when ig.CONFIG.PATHFINDING.BUILD_WITH_LEVEL is enabled. IMPORTANT: if using a ig.PathfindingMap, the tilesize must match the ig.CollisionMap's tilesize!Name Type Argument Description collisionMapig.CollisionMap map to determine walkability of nodes pathfindingMapig.PathfindingMap <optional>
map to add settings to each node - Source:
-
<static> unload()
-
Unload pathfinding and clear map, grid, etc. IMPORTANT: this is called automatically by ig.GameExtended#unloadLevel.
- Source:

Impact++