mtd/Scripts/visualized_path.gd

28 lines
819 B
GDScript3
Raw Normal View History

extends Path3D
class_name VisualizedPath
var visual_scene = preload("res://Scenes/path_visual_thing.tscn")
var length := 0.0
var visualizer_points = []
func spawn_visualizer_points() -> void:
var new_length = curve.get_baked_length()
for x in floori(new_length) - visualizer_points.size():
var point = visual_scene.instantiate()
visualizer_points.append(point)
add_child(point)
length = new_length
#print(str(int(length)) + " / " + str(visualizer_points.size()) + ", diff: " + str(visualizer_points.size() - length))
for x in visualizer_points.size():
visualizer_points[x].progress_ratio = float(x) / visualizer_points.size()
func disable_visualization():
for x in visualizer_points:
x.set_world_visible(false)
func enable_visualization():
for x in visualizer_points:
x.set_world_visible(true)