Click or drag to resize

AStar2DAddPoint Method

Adds a new point at the given position with the given identifier. The id must be 0 or larger, and the weight_scale must be 1 or larger.

The weight_scale is multiplied by the result of _ComputeCost(Int32, Int32) when determining the overall cost of traveling across a segment from a neighboring point to this point. Thus, all else being equal, the algorithm prefers points with lower weight_scales to form a path.

var astar = AStar2D.new()
astar.add_point(1, Vector2(1, 0), 4) # Adds the point (1, 0) with weight_scale 4 and id 1

If there already exists a point for the given id, its position and weight scale are updated to the given values.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public void AddPoint(
	int id,
	Vector2 position,
	float weightScale = 1f
)

Parameters

id
Type: SystemInt32

[Missing <param name="id"/> documentation for "M:Godot.AStar2D.AddPoint(System.Int32,Godot.Vector2,System.Single)"]

position
Type: GodotVector2

[Missing <param name="position"/> documentation for "M:Godot.AStar2D.AddPoint(System.Int32,Godot.Vector2,System.Single)"]

weightScale (Optional)
Type: SystemSingle

[Missing <param name="weightScale"/> documentation for "M:Godot.AStar2D.AddPoint(System.Int32,Godot.Vector2,System.Single)"]

See Also