made bullet with a camera on the end. other tweaks
This commit is contained in:
@@ -10,7 +10,7 @@ const SPRINT_SPEED = 15.0
|
||||
const DASH_SPEED = 40
|
||||
const SLOWSPEED = .1
|
||||
const MAX_STAMINA : float = 100
|
||||
const STAMINA_DRAIN = 200
|
||||
const STAMINA_DRAIN = 100 #multiplied times the delta when draining
|
||||
|
||||
var speed
|
||||
var double_jump = true
|
||||
@@ -75,6 +75,7 @@ var held_item_angular_damp_cache
|
||||
var held_item_gravity_cache
|
||||
var held_item_mass_cache
|
||||
var held_item_rotation = Vector3(0,0,0)
|
||||
var gamespeed_controlled = false
|
||||
|
||||
# Slow Down Variables
|
||||
var remaining_stamina : float = MAX_STAMINA
|
||||
@@ -84,6 +85,7 @@ var picked_up_text
|
||||
var pickup_announce = load("res://assets/pickup_announce.tscn")
|
||||
var dead_announce = load("res://assets/dead_announce.tscn")
|
||||
var pickupmsg
|
||||
var controlled_elsewhere = false
|
||||
|
||||
@onready var crosshair = $Head/Recoil/Camera3D/Crosshair
|
||||
@onready var head = $Head
|
||||
@@ -110,11 +112,13 @@ var pickupmsg
|
||||
@onready var stand_check: RayCast3D = $StandCheck
|
||||
@onready var r_hand_test: MeshInstance3D = $Head/Recoil/Camera3D/WeaponHolder/RHandTest
|
||||
@onready var l_hand_test: MeshInstance3D = $Head/Recoil/Camera3D/WeaponHolder/LHandTest
|
||||
@onready var enemy_killed_audio: AudioStreamPlayer = $Audio/EnemyKilled
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
SignalBus.enemy_hit.connect(enemy_hit)
|
||||
SignalBus.enemy_killed.connect(enemy_killed)
|
||||
|
||||
weapon_holder_start_rot = weapon_holder.rotation
|
||||
weapon_holder_start_pos = weapon_holder.position
|
||||
@@ -134,20 +138,20 @@ func _ready():
|
||||
AudioServer.set_bus_volume_db(0,-80)
|
||||
|
||||
func _input(event) -> void:
|
||||
|
||||
if !level_control.paused:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(-event.relative.x * SENSITIVITY)
|
||||
head.rotate_x(-event.relative.y * SENSITIVITY)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
else:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(event.relative.x * .00001)
|
||||
head.rotate_x(event.relative.y * .00001)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
|
||||
if !controlled_elsewhere:
|
||||
if !level_control.paused:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(-event.relative.x * SENSITIVITY)
|
||||
head.rotate_x(-event.relative.y * SENSITIVITY)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
else:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(event.relative.x * .00001)
|
||||
head.rotate_x(event.relative.y * .00001)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
if !dead and !level_control.paused:
|
||||
@@ -219,13 +223,10 @@ func _physics_process(delta):
|
||||
health_indicator.color = lerp(Color(0.471, 0, 0, 0), Color(0.471, 0, 0, .25),health_opacity)
|
||||
|
||||
# Moving Fast Sound
|
||||
#initiate fast movement -- may be done with this block
|
||||
#change sounds with speed
|
||||
var wind_volume = clamp(velocity.length()/20,0,1) #expected max velocity for effect
|
||||
ear_wind.volume_db = lerp(-80,0,wind_volume)
|
||||
|
||||
if moving_fast:
|
||||
var wind_volume = clamp( velocity.length() - 20 ,-80,10)
|
||||
ear_wind.volume_db = wind_volume
|
||||
#reset at apex
|
||||
|
||||
#cache fastest speed
|
||||
if abs(velocity.y) > moving_fast_top_speed:
|
||||
moving_fast_top_speed = abs(velocity.y)
|
||||
@@ -243,23 +244,25 @@ func _physics_process(delta):
|
||||
# Game Speed
|
||||
if !level_control.paused:
|
||||
if Input.is_action_pressed("slow_down") and remaining_stamina > 0 :
|
||||
Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, delta * 20)
|
||||
gun.random_spread_amt = 0
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
|
||||
if sensitivity_shift == true:
|
||||
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100)
|
||||
if remaining_stamina > 0:
|
||||
remaining_stamina = clamp(remaining_stamina - (delta * STAMINA_DRAIN),0,MAX_STAMINA)
|
||||
if !gamespeed_controlled:
|
||||
Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, delta * 20)
|
||||
gun.random_spread_amt = 0
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
|
||||
if sensitivity_shift == true:
|
||||
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100)
|
||||
if remaining_stamina > 0:
|
||||
remaining_stamina = clamp(remaining_stamina - (delta * STAMINA_DRAIN),0,MAX_STAMINA)
|
||||
else:
|
||||
Engine.time_scale = lerp(Engine.time_scale, 1.0, delta * 50)
|
||||
gun.random_spread_amt = gun.random_spread_start
|
||||
AudioServer.set_bus_effect_enabled(0,0,false)
|
||||
if sensitivity_shift == true:
|
||||
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
|
||||
SENSITIVITY = start_sensitivity
|
||||
if remaining_stamina < MAX_STAMINA and !Input.is_action_pressed("slow_down"):
|
||||
remaining_stamina = clamp(remaining_stamina + (delta * STAMINA_DRAIN/10), 0, MAX_STAMINA)
|
||||
if !gamespeed_controlled:
|
||||
Engine.time_scale = lerp(Engine.time_scale, 1.0, delta * 50)
|
||||
gun.random_spread_amt = gun.random_spread_start
|
||||
AudioServer.set_bus_effect_enabled(0,0,false)
|
||||
if sensitivity_shift == true:
|
||||
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
|
||||
SENSITIVITY = start_sensitivity
|
||||
if remaining_stamina < MAX_STAMINA and !Input.is_action_pressed("slow_down"):
|
||||
remaining_stamina = clamp(remaining_stamina + (delta * STAMINA_DRAIN/10), 0, MAX_STAMINA)
|
||||
|
||||
|
||||
# Reloading
|
||||
@@ -354,6 +357,7 @@ func _physics_process(delta):
|
||||
weapon_sway(delta)
|
||||
weapon_bob(velocity.length(), delta)
|
||||
|
||||
|
||||
func _headbob(time) -> Vector3:
|
||||
var pos = Vector3.ZERO
|
||||
pos.y = sin(time * BOB_FREQ) * BOB_AMP
|
||||
@@ -414,6 +418,9 @@ func enemy_hit():
|
||||
camera.add_child(hitmarker_spawn)
|
||||
hit_indicator.play()
|
||||
|
||||
func enemy_killed():
|
||||
enemy_killed_audio.play()
|
||||
|
||||
func toggle_hud(hud_on):
|
||||
|
||||
if dead:
|
||||
@@ -426,7 +433,7 @@ func toggle_hud(hud_on):
|
||||
func grab_moveable(body):
|
||||
moveable_holder.global_position = body.global_position
|
||||
held_item = body
|
||||
held_item_rotation = body.rotation
|
||||
held_item_rotation = Vector3(0,0,0)#body.rotation
|
||||
#cache rigidbody settings
|
||||
held_item_linear_damp_cache = body.linear_damp
|
||||
held_item_angular_damp_cache = body.angular_damp
|
||||
@@ -443,8 +450,9 @@ func hold_item():
|
||||
if held_item != null:
|
||||
var held_dir = moveable_holder.global_position - held_item.global_position
|
||||
var held_av = held_item_rotation - held_item.rotation
|
||||
held_item.linear_velocity = held_dir * 30
|
||||
held_item.angular_velocity = held_av * 10
|
||||
held_item.linear_velocity = held_dir * 5
|
||||
held_item.look_at(camera.global_position)
|
||||
#held_item.angular_velocity = held_av * 10
|
||||
|
||||
#break when moved too far away
|
||||
var distance_from_player = abs(self.global_position - held_item.global_position)
|
||||
|
||||
Reference in New Issue
Block a user