portal-demo/scripts/cinematic_camera.gd
2025-06-18 22:37:47 +02:00

22 lines
593 B
GDScript

extends Camera3D
@export_range(1, 100, 0.1, "suffix:s") var travel_time: float
@export var path: Path3D
@export var follower: PathFollow3D
@export var target: MeshInstance3D
func _ready() -> void:
assert (path != null)
assert(follower != null)
assert(target != null)
var t = get_tree().create_tween()
t.set_trans(Tween.TRANS_CUBIC)
t.set_ease(Tween.EASE_IN_OUT)
t.tween_property(follower, "progress_ratio", 1, travel_time)
t.tween_callback(get_tree().quit.bind(0))
func _process(delta: float) -> void:
look_at(target.global_position)
global_position = follower.global_position