How to make line2d follows a path2d?

Godot Version

4.2.2

Question

question

You get the Path2D.curve baked points with Curve2D.get_baked_points() and set it to Line2D.points

Example:

extends Path2D


@onready var line_2d: Line2D = $Line2D


func _ready() -> void:
	var points = curve.get_baked_points()
	line_2d.points = points

Result: