Instance Propertymigueldeicaza.swiftgodot 0.45.0SwiftGodot
diagonalMode
A specific DiagonalMode
mode which will force the path to avoid or accept the specified diagonals.
final var diagonalMode: AStarGrid2D.DiagonalMode { get set }
Other members in extension
Types
Type members
Instance members
var cellSize: Vector2
The size of the point cell which will be applied to calculate the resulting point position returned by
getPointPath(fromId:toId:)
. If changed,update
needs to be called before finding the next path.var defaultComputeHeuristic: AStarGrid2D.Heuristic
The default
Heuristic
which will be used to calculate the cost between two points if_computeCost(fromId:toId:)
was not overridden.var defaultEstimateHeuristic: AStarGrid2D.Heuristic
The default
Heuristic
which will be used to calculate the cost between the point and the end point if_estimateCost(fromId:toId:)
was not overridden.var jumpingEnabled: Bool
Enables or disables jumping to skip up the intermediate points and speeds up the searching algorithm.
var offset: Vector2
The offset of the grid which will be applied to calculate the resulting point position returned by
getPointPath(fromId:toId:)
. If changed,update
needs to be called before finding the next path.var region: Rect2i
The region of grid cells available for pathfinding. If changed,
update
needs to be called before finding the next path.var size: Vector2i
The size of the grid (number of cells of size
cellSize
on each axis). If changed,update
needs to be called before finding the next path.func clear(
) Clears the grid and sets the
region
toRect2i(0, 0, 0, 0)
.func fillSolidRegion(Rect2i, solid: Bool
) Fills the given
region
on the grid with the specified value for the solid flag.func fillWeightScaleRegion(Rect2i, weightScale: Double
) Fills the given
region
on the grid with the specified value for the weight scale.func getIdPath(fromId: Vector2i, toId: Vector2i
) -> VariantCollection<Vector2i> Returns an array with the IDs of the points that form the path found by AStar2D between the given points. The array is ordered from the starting point to the ending point of the path.
func getPointPath(fromId: Vector2i, toId: Vector2i
) -> PackedVector2Array Returns an array with the points that are in the path found by
AStarGrid2D
between the given points. The array is ordered from the starting point to the ending point of the path.func getPointPosition(id: Vector2i
) -> Vector2 Returns the position of the point associated with the given
id
.func getPointWeightScale(id: Vector2i
) -> Double Returns the weight scale of the point associated with the given
id
.func isDirty(
) -> Bool Indicates that the grid parameters were changed and
update
needs to be called.func isInBounds(x: Int32, y: Int32
) -> Bool Returns
true
if thex
andy
is a valid grid coordinate (id), i.e. if it is insideregion
. Equivalent toregion.has_point(Vector2i(x, y))
.func isInBoundsv(id: Vector2i
) -> Bool Returns
true
if theid
vector is a valid grid coordinate, i.e. if it is insideregion
. Equivalent toregion.has_point(id)
.func isPointSolid(id: Vector2i
) -> Bool Returns
true
if a point is disabled for pathfinding. By default, all points are enabled.func setPointSolid(id: Vector2i, solid: Bool
) Disables or enables the specified point for pathfinding. Useful for making an obstacle. By default, all points are enabled.
func setPointWeightScale(id: Vector2i, weightScale: Double
) Sets the
weightScale
for the point with the givenid
. TheweightScale
is multiplied by the result of_computeCost(fromId:toId:)
when determining the overall cost of traveling across a segment from a neighboring point to this point.func update(
) Updates the internal state of the grid according to the parameters to prepare it to search the path. Needs to be called if parameters like
region
,cellSize
oroffset
are changed.isDirty
will returntrue
if this is the case and this needs to be called.
Show implementation details (2)
Hide implementation details
func _computeCost(fromId: Vector2i, toId: Vector2i
) -> Double Called when computing the cost between two connected points.
func _estimateCost(fromId: Vector2i, toId: Vector2i
) -> Double Called when estimating the cost between a point and the path’s ending point.