dead camera rotation working and focusing on target
This commit is contained in:
@@ -2,17 +2,18 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/dead_cam.gd" id="1_qxtd8"]
|
[ext_resource type="Script" path="res://scripts/dead_cam.gd" id="1_qxtd8"]
|
||||||
|
|
||||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_ybt8m"]
|
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_2gkpp"]
|
||||||
dof_blur_far_enabled = true
|
dof_blur_far_enabled = true
|
||||||
dof_blur_far_distance = 7.0
|
|
||||||
dof_blur_far_transition = 10.0
|
|
||||||
dof_blur_near_enabled = true
|
dof_blur_near_enabled = true
|
||||||
|
dof_blur_near_transition = 4.0
|
||||||
|
dof_blur_amount = 0.2
|
||||||
|
|
||||||
[node name="DeadCam" type="Node3D" groups=["spawned"]]
|
[node name="DeadCam" type="Node3D" groups=["spawned"]]
|
||||||
script = ExtResource("1_qxtd8")
|
script = ExtResource("1_qxtd8")
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
attributes = SubResource("CameraAttributesPractical_ybt8m")
|
attributes = SubResource("CameraAttributesPractical_2gkpp")
|
||||||
|
fov = 13.6855
|
||||||
|
|
||||||
[node name="LookRay" type="RayCast3D" parent="."]
|
[node name="LookRay" type="RayCast3D" parent="."]
|
||||||
target_position = Vector3(0, 0, -1)
|
target_position = Vector3(0, 0, -1)
|
||||||
|
|||||||
@@ -1170,6 +1170,7 @@ health_drop_enabled = false
|
|||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("2_f87c2")]
|
[node name="Player" parent="." instance=ExtResource("2_f87c2")]
|
||||||
transform = Transform3D(-0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866025, -16.0295, 1.4435, 12.1166)
|
transform = Transform3D(-0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866025, -16.0295, 1.4435, 12.1166)
|
||||||
|
AUDIO = false
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(0.420794, 0.292511, -0.858703, -0.23587, 0.949309, 0.207791, 0.875956, 0.115105, 0.468458, 0, 0, 0)
|
transform = Transform3D(0.420794, 0.292511, -0.858703, -0.23587, 0.949309, 0.207791, 0.875956, 0.115105, 0.468458, 0, 0, 0)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ extends Node3D
|
|||||||
|
|
||||||
@export var MOVE_SPEED = 15
|
@export var MOVE_SPEED = 15
|
||||||
@export var CAMERA_LOOK_SPEED = 20
|
@export var CAMERA_LOOK_SPEED = 20
|
||||||
@export var FOV_CHANGE_SPEED = 200
|
@export var FOV_CHANGE_SPEED = 20
|
||||||
|
|
||||||
@onready var look_ray = $LookRay
|
@onready var look_ray = $LookRay
|
||||||
@onready var camera = $Camera3D
|
@onready var camera = $Camera3D
|
||||||
@@ -14,12 +14,12 @@ var target : Node
|
|||||||
var respawn_position
|
var respawn_position
|
||||||
var respawn_rotation
|
var respawn_rotation
|
||||||
var respawn_fov
|
var respawn_fov
|
||||||
var camera_start_fov
|
const DEAD_CAM_FOV = 50.0
|
||||||
var respawn = false
|
var respawn = false
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
camera_start_fov = camera.fov
|
camera.fov = respawn_fov
|
||||||
timer.start()
|
timer.start()
|
||||||
for i in target.outline_meshes:
|
for i in target.outline_meshes:
|
||||||
print(i)
|
print(i)
|
||||||
@@ -28,19 +28,24 @@ func _ready():
|
|||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
|
||||||
|
var focus_dist = abs(camera.global_position - target.global_position)
|
||||||
|
|
||||||
|
camera.attributes.dof_blur_far_distance = focus_dist.z + 3
|
||||||
|
camera.attributes.dof_blur_near_distance = focus_dist.z - 1
|
||||||
|
|
||||||
# Move towards and look at target
|
# Move towards and look at target
|
||||||
if target != null and respawn == false:
|
if target != null and respawn == false:
|
||||||
#calculate move direction
|
#calculate move direction
|
||||||
var target_pos_adjusted = Vector3(target.position.x -2,target.position.y + 4,target.position.z -2)
|
var target_pos_adjusted = Vector3(target.position.x -2,target.position.y + 4,target.position.z -2)
|
||||||
#camera.fov = lerp(respawn_fov,10.0,delta * FOV_CHANGE_SPEED)
|
#camera.fov = lerp(respawn_fov,DEAD_CAM_FOV,delta*100)
|
||||||
position = lerp(position,target_pos_adjusted,delta * MOVE_SPEED)
|
position = lerp(position,target_pos_adjusted,delta * MOVE_SPEED)
|
||||||
look_ray.look_at(Vector3(target.global_position), Vector3.UP)
|
look_ray.look_at(Vector3(target.global_position), Vector3.UP)
|
||||||
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
|
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
|
||||||
elif respawn == true:
|
elif respawn == true:
|
||||||
position = lerp(position,respawn_position,delta * MOVE_SPEED)
|
position = lerp(position,respawn_position,delta * MOVE_SPEED)
|
||||||
camera.rotation = lerp(camera.rotation,Vector3(0,0,0),delta * CAMERA_LOOK_SPEED)
|
|
||||||
camera.global_transform.basis = lerp(camera.global_transform.basis,respawn_rotation,delta * CAMERA_LOOK_SPEED)
|
camera.global_transform.basis = lerp(camera.global_transform.basis,respawn_rotation,delta * CAMERA_LOOK_SPEED)
|
||||||
#camera.fov = lerp(camera.fov,respawn_fov,delta * FOV_CHANGE_SPEED)
|
#camera.fov = lerp(DEAD_CAM_FOV,respawn_fov,delta * FOV_CHANGE_SPEED)
|
||||||
if abs(position.x - respawn_position.x) <=.2:
|
if abs(position.x - respawn_position.x) <=.2:
|
||||||
reload_level()
|
reload_level()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user