You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
621 B
30 lines
621 B
extends Camera3D
|
|
|
|
@export var rail : Path3D
|
|
@export var target : Node3D
|
|
@export var seek_easing : float
|
|
|
|
var target_pos
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func init():
|
|
target_pos = target.position
|
|
|
|
func seek_target():
|
|
|
|
if target_pos != target.position:
|
|
target_pos = target_pos.move_toward( target.position , target.position.distance_to(target_pos)/seek_easing )
|
|
look_at( target_pos + Vector3(0.0,0.70,0.0) )
|
|
|
|
|
|
func constraint_to_rail():
|
|
position = rail.curve.get_closest_point( target.position )
|
|
|
|
func _ready():
|
|
init()
|
|
|
|
|
|
func _process(delta):
|
|
constraint_to_rail()
|
|
seek_target()
|