teststrecke-game/scripts/generate_road_polyon.gd

27 lines
775 B
GDScript3
Raw Normal View History

2024-12-17 21:26:23 +00:00
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.
2024-12-21 13:05:37 +00:00
func _ready() -> void:
2024-12-17 21:26:23 +00:00
var road=PackedVector2Array()
road.append_array(line_road_right.points)
2024-12-21 13:05:37 +00:00
if line_road_right.closed and line_road_right.points.size()>0:
2024-12-17 21:26:23 +00:00
road.append(line_road_right.points[0]) #add first point again to close gap
2024-12-21 13:05:37 +00:00
if line_road_left.closed and line_road_left.points.size()>0:
2024-12-17 21:26:23 +00:00
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