FantasyRun/Tiles/Tile.gd

47 lines
955 B
GDScript

extends Node3D
class_name Tile
@onready var follow = $MainPath/Follow as PathFollow3D
@onready var spawn_point = $SpawnPoint as Marker3D
@onready var progress_marker = $MainPath/Follow/ProgressMarker as Marker3D
var paths: Array[Path3D]
var path_index: int = 0
var path: Path3D:
get = get_current_path
var marker_position: Vector3:
get:
return progress_marker.global_position
var marker_rotation: Vector3:
get:
return progress_marker.global_rotation
func _ready():
paths.append($MainPath)
func _process(delta):
if is_equal_approx(follow.progress_ratio, 1) and has_next_path():
path_index += 1
follow = Utils.get_first_node_of_type(path, PathFollow3D) as PathFollow3D
progress_marker.reparent(follow)
func get_current_path() -> Path3D:
return paths[path_index]
func has_next_path() -> bool:
return path_index + 1 < paths.size()
func get_next_path() -> Path3D:
if has_next_path():
return paths[path_index+1]
return null