@tool extends Area3D @export var path: Path3D: set = set_path @export var speed: float = 5.0 var follow: PathFollow3D var marker: Marker3D var total_distance: float = 0.0 func _ready() -> void: if path == null or path is not Path3D: printerr("path is not set to a Path3D") return follow = path.get_node("Follow") marker = follow.get_node("Marker") func _process(delta): if path == null: return global_position = marker.global_position if follow.progress_ratio >= 1: return var travel = speed * delta follow.progress += travel total_distance += travel #if is_equal_approx(follow.progress, change_distance): #path = $Path3D2 #follow = path.get_node(("Follow")) #change_distance = path.curve.get_baked_length() #marker.reparent(follow) func set_path(new_path: Path3D): if new_path is not Path3D: printerr("path must be a Path3D") return path = new_path follow = path.get_node("Follow") marker = follow.get_node("Marker") update_configuration_warnings() func _get_configuration_warnings() -> PackedStringArray: var warnings = [] if path == null or path is not Path3D: warnings.append("path must be set to a Path3D.") return warnings