@tool
class_name Trail extends Line2D

@export var max_points = 10
var trail_points : PackedVector2Array = []

func _ready():
	points = []

func _physics_process(_delta):
	trail_points.append(global_position)

	if trail_points.size() > max_points:
		trail_points.remove_at(0)
	
	var local_points : PackedVector2Array = []
	for p in trail_points:
		local_points.append(to_local(p))

	points = local_points
