teststrecke-game/scripts/generate_road_polyon.gd
2024-12-21 14:05:37 +01:00

26 lines
775 B
GDScript

extends Polygon2D
@export var line_road_left: Line2D
@export var line_road_right: Line2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var road=PackedVector2Array()
road.append_array(line_road_right.points)
if line_road_right.closed and line_road_right.points.size()>0:
road.append(line_road_right.points[0]) #add first point again to close gap
if line_road_left.closed and line_road_left.points.size()>0:
road.append(line_road_left.points[0]) #add first point to close gap
var reversed=PackedVector2Array(line_road_left.points)
reversed.reverse()
road.append_array(reversed)
polygon=road
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass