FantasyRun/world.gd
2024-09-29 19:10:44 -07:00

28 lines
726 B
GDScript

extends Node3D
@onready var path: Path3D = $Path
@onready var character: Character = $Character
var change_distance: float
var paths: Array
var current_path: int = 0
func _ready() -> void:
paths = Utils.get_nodes_of_class(self, Path3D)
if paths.size() == 0:
printerr("There are no Path3Ds in the scene.")
return
change_distance = paths[current_path].curve.get_baked_length()
if character.path == null:
character.path = paths[current_path]
func _process(delta: float) -> void:
if is_equal_approx(character.follow.progress, change_distance):
current_path += 1
if current_path >= paths.size():
return
character.path = paths[current_path]
change_distance = paths[current_path].curve.get_baked_length()