Click or drag to resize

AStar2DGetClosestPositionInSegment Method

Returns the closest position to to_position that resides inside a segment between two connected points.

var astar = AStar2D.new()
astar.add_point(1, Vector2(0, 0))
astar.add_point(2, Vector2(0, 5))
astar.connect_points(1, 2)
var res = astar.get_closest_position_in_segment(Vector2(3, 3)) # Returns (0, 3)

The result is in the segment that goes from y = 0 to y = 5. It's the closest position in the segment to the given point.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public Vector2 GetClosestPositionInSegment(
	Vector2 toPosition
)

Parameters

toPosition
Type: GodotVector2

[Missing <param name="toPosition"/> documentation for "M:Godot.AStar2D.GetClosestPositionInSegment(Godot.Vector2)"]

Return Value

Type: Vector2

[Missing <returns> documentation for "M:Godot.AStar2D.GetClosestPositionInSegment(Godot.Vector2)"]

See Also