death camera mostly working
This commit is contained in:
32
scripts/dead_cam.gd
Normal file
32
scripts/dead_cam.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
@export var MOVE_SPEED = 15
|
||||
@export var CAMERA_LOOK_SPEED = 20
|
||||
|
||||
@onready var look_ray = $LookRay
|
||||
@onready var camera = $Camera3D
|
||||
|
||||
var target : Node
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
# Move towards and look at target
|
||||
|
||||
#calculate move direction
|
||||
var target_pos_adjusted = Vector3(target.position.x -2,target.position.y + 4,target.position.z -2)
|
||||
|
||||
position = lerp(position,target_pos_adjusted,delta * MOVE_SPEED)
|
||||
|
||||
|
||||
look_ray.look_at(Vector3(target.global_position), Vector3.UP)
|
||||
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
|
||||
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().reload_current_scene()
|
||||
queue_free()
|
||||
Reference in New Issue
Block a user