Added the 3d/lib folder to the project tracking
This commit is contained in:
+13
-6
@@ -2,25 +2,32 @@ extends Camera3D
|
||||
|
||||
@export var rail : Path3D
|
||||
@export var target : Node3D
|
||||
@export var seek_easing : float
|
||||
|
||||
@export var seek_easing : float = 1.0
|
||||
var crv : Curve3D
|
||||
var cur_offset : float
|
||||
var tgt_offset : float
|
||||
var target_pos
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func init():
|
||||
crv = rail.curve
|
||||
target_pos = target.position
|
||||
tgt_offset = crv.get_closest_offset( 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 )
|
||||
target_pos = target_pos.move_toward( target.position , target.position.distance_to(target_pos)/seek_easing ) # distancia entre los puntos dividido entre easing
|
||||
look_at( target_pos + Vector3(0.0,0.70,0.0) )
|
||||
|
||||
|
||||
func constraint_to_rail():
|
||||
position = rail.curve.sample_baked( rail.curve.get_closest_offset( target.position ) )
|
||||
#position = rail.curve.get_closest_point( target.position )
|
||||
|
||||
tgt_offset = crv.get_closest_offset( target.position )
|
||||
cur_offset = move_toward( cur_offset , tgt_offset , abs(tgt_offset - cur_offset )/ (seek_easing * 100) )
|
||||
print((tgt_offset - cur_offset ))
|
||||
position = crv.sample_baked( cur_offset )
|
||||
|
||||
func _ready():
|
||||
init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user