dead camera much improved and has the ability to step through multiple stages
This commit is contained in:
@@ -130,8 +130,6 @@ func cleared():
|
||||
clearedmsg.queue_free()
|
||||
|
||||
func die():
|
||||
Engine.time_scale = .05
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
var deadmsg = DEAD_ANNOUNCE.instantiate()
|
||||
get_parent().add_child(deadmsg)
|
||||
var instance_dead = dead_player.instantiate()
|
||||
@@ -147,6 +145,7 @@ func die():
|
||||
player.dead = true
|
||||
player.toggle_hud(true)
|
||||
player.gun.visible = false
|
||||
player.health_indicator.color = Color(0.471, 0, 0, 0)
|
||||
player.crosshair.visible = false
|
||||
|
||||
|
||||
|
||||
@@ -16,4 +16,3 @@ func _ready():
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
position = Vector2(viewportWidth/2 - (size.x/2), viewportHeight/2 - (size.y/2))
|
||||
|
||||
|
||||
@@ -1,29 +1,39 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const DEAD_CAM_FOV = 50.0
|
||||
|
||||
@export var MOVE_SPEED = 30
|
||||
@export var CAMERA_LOOK_SPEED = 20
|
||||
@export var FOV_CHANGE_SPEED = 40
|
||||
|
||||
@onready var look_ray = $LookRay
|
||||
@onready var camera = $Camera3D
|
||||
@onready var camera = $CameraRigid/Camera3D
|
||||
@onready var camera_rigid: RigidBody3D = $CameraRigid
|
||||
@onready var timer = $Timer
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var whiteout = $Whiteout
|
||||
const ENEMY_TAUNT = preload("res://assets/enemy_taunt.tscn")
|
||||
@onready var ENEMY_TAUNT = preload("res://assets/enemy_taunt.tscn")
|
||||
@onready var animation_player = $AnimationPlayer
|
||||
@onready var cam_target: Node3D = $CamTarget
|
||||
|
||||
var focus_dist
|
||||
var target : Node
|
||||
var focus_target
|
||||
var respawn_position
|
||||
var respawn_rotation
|
||||
var taunt_node
|
||||
var respawn_fov
|
||||
const DEAD_CAM_FOV = 50.0
|
||||
var respawn = false
|
||||
var anim_step = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
|
||||
Engine.time_scale = .05
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
|
||||
#set FOV
|
||||
camera.fov = respawn_fov
|
||||
|
||||
@@ -31,7 +41,7 @@ func _ready():
|
||||
level_control.player.stamina_counter.visible = false
|
||||
|
||||
#start timer
|
||||
timer.start()
|
||||
timer.start(.3)
|
||||
|
||||
#highlight target
|
||||
if target != null:
|
||||
@@ -39,6 +49,7 @@ func _ready():
|
||||
taunt_spawn.text = taunt_spawn.taunts.pick_random()
|
||||
target.add_child(taunt_spawn)
|
||||
taunt_spawn.global_transform.origin = target.position + Vector3(0,2,0)
|
||||
taunt_node = taunt_spawn
|
||||
|
||||
|
||||
for i in target.outline_meshes:
|
||||
@@ -61,24 +72,43 @@ func _process(delta):
|
||||
camera.attributes.dof_blur_near_distance = focus_dist - 2
|
||||
|
||||
if target == null:
|
||||
respawn = true
|
||||
anim_step = 3
|
||||
|
||||
# Move towards and look at target
|
||||
if respawn == false:
|
||||
#calculate move direction
|
||||
var target_pos_adjusted = Vector3(target.position.x -4,target.position.y + 4,target.position.z -4)
|
||||
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)
|
||||
camera.fov = lerp(camera.fov, 40.0, delta * 5)
|
||||
|
||||
elif respawn == true:
|
||||
animation_player.play("whiteout")
|
||||
camera_rigid.global_position = lerp(camera_rigid.global_position,cam_target.global_position, delta * 100)
|
||||
|
||||
match anim_step:
|
||||
0:
|
||||
#Show enemy that killed player
|
||||
var target_pos_adjusted = Vector3(target.position.x -4,target.position.y + 4,target.position.z -4)
|
||||
cam_target.global_position = lerp(cam_target.global_position,target_pos_adjusted,delta * MOVE_SPEED)
|
||||
look_ray.global_position = target_pos_adjusted
|
||||
look_ray.look_at(Vector3(target.global_position), Vector3.UP)
|
||||
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
|
||||
camera.fov = lerp(camera.fov, 40.0, delta * 5)
|
||||
1:
|
||||
#aim at player from enemy
|
||||
Engine.time_scale = .1
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
taunt_node.visible = false
|
||||
var target_pos_adjusted = Vector3(target.position.x,target.position.y + 2.1,target.position.z)
|
||||
cam_target.global_position = lerp(cam_target.global_position,target_pos_adjusted,delta * MOVE_SPEED)
|
||||
look_ray.global_position = target.global_position
|
||||
look_ray.look_at(Vector3(level_control.player.global_position), Vector3.UP)
|
||||
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
|
||||
camera.fov = lerp(camera.fov, 110.0, delta * 100)
|
||||
2:
|
||||
var target_pos_adjusted = Vector3(target.position.x,target.position.y + 2.1,target.position.z)
|
||||
cam_target.global_position = lerp(cam_target.global_position,target_pos_adjusted,delta * MOVE_SPEED)
|
||||
look_ray.global_position = target.global_position
|
||||
look_ray.look_at(Vector3(level_control.player.global_position), Vector3.UP)
|
||||
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
|
||||
camera.fov = lerp(camera.fov, 110.0, delta * 100)
|
||||
animation_player.play("whiteout")
|
||||
|
||||
|
||||
func _on_timer_timeout():
|
||||
respawn = true
|
||||
|
||||
anim_step += 1
|
||||
print("ANIM STEP " +str(anim_step))
|
||||
|
||||
func reload_level():
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
13
scripts/hitmarker.gd
Normal file
13
scripts/hitmarker.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends TextureRect
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func anim_end():
|
||||
queue_free()
|
||||
@@ -56,6 +56,7 @@ var gun : Node
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var interact_ray = $Head/Recoil/Camera3D/InteractRay
|
||||
@onready var bullet_ray = $Head/Recoil/Camera3D/BulletRay
|
||||
@onready var hitmarker = load("res://hitmarker.tscn")
|
||||
var instance_bullet
|
||||
var instance_casing
|
||||
var instance_mag
|
||||
@@ -85,7 +86,6 @@ var dead_announce = load("res://assets/dead_announce.tscn")
|
||||
var pickupmsg
|
||||
|
||||
@onready var crosshair = $Head/Recoil/Camera3D/Crosshair
|
||||
@onready var hitmarker: TextureRect = $Head/Recoil/Camera3D/Hitmarker
|
||||
@onready var head = $Head
|
||||
@onready var camera = $Head/Recoil/Camera3D
|
||||
@onready var world_environment = $"../WorldEnvironment"
|
||||
@@ -122,6 +122,8 @@ func _ready():
|
||||
health_indicator.size = Vector2(viewportWidth,viewportHeight)
|
||||
health_indicator.color = Color(0.471, 0, 0, 0)
|
||||
|
||||
crt_filter.visible = false
|
||||
|
||||
#turn off audio if unchecked in player
|
||||
if AUDIO == false:
|
||||
AudioServer.set_bus_volume_db(0,-80)
|
||||
@@ -397,9 +399,8 @@ func weapon_select(gun_id):
|
||||
level_control.gun_spawn(gun_id)
|
||||
|
||||
func enemy_hit():
|
||||
hitmarker.visible = true
|
||||
await get_tree().create_timer(.1).timeout
|
||||
hitmarker.visible = false
|
||||
var hitmarker_spawn = hitmarker.instantiate()
|
||||
camera.add_child(hitmarker_spawn)
|
||||
|
||||
func toggle_hud(hud_on):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user