class_name DebugDraw extends Control const COLOR := Color.ORANGE const WIDTH := 4 var lines: Array = [] func _process(_delta: float) -> void: if visible: queue_redraw() else: lines = [] func draw_vector(vec: Vector3, origin: Vector3) -> void: var camera := get_viewport().get_camera_3d() var start := camera.unproject_position(origin) var end := camera.unproject_position(origin + vec) lines.push_back([start, end]) func _draw() -> void: while lines: var line: Array[Vector2] = [] line.assign(lines.pop_back() as Array) draw_line(line[0], line[1], COLOR, WIDTH)