added crouch slide, disabled fov zoom on slow down for now

This commit is contained in:
derek
2024-12-09 12:56:04 -06:00
parent 6c16607956
commit a1518945d4
16 changed files with 152 additions and 43 deletions

View File

@@ -47,7 +47,7 @@ var start_sensitivity
@export_subgroup("Head Bob & Gun Sway")
@export var t_bob = 1.0
@export var weapon_holder : Node3D
@export var weapon_sway_amount : float = .14
@export var weapon_sway_amount : float = .09
@export var weapon_rotation_amount : float = .07
@export_subgroup("FOV")
@export var BASE_FOV : float = 80
@@ -206,7 +206,16 @@ func _physics_process(delta):
velocity.y += JUMP_VELOCITY
double_jump = false
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if air_dash > 0:
velocity.x += direction.x * DASH_SPEED
velocity.z += direction.z * DASH_SPEED
air_dash -= 1
if Input.is_action_just_pressed("crouch"):
if crouched:
if !crouch_check.is_colliding():
@@ -220,19 +229,10 @@ func _physics_process(delta):
crouched = !crouched
recoil.add_recoil(Vector3(.2,0,0),5,10)
crouch_audio.play()
velocity.y -= 15
if is_on_floor():
velocity += direction * 20
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if air_dash > 0:
velocity.x += direction.x * DASH_SPEED
velocity.z += direction.z * DASH_SPEED
air_dash -= 1
print("AIR DASH " +str(air_dash))
#walking
if is_on_floor() and !is_climbing:
if direction:
@@ -293,22 +293,19 @@ func _physics_process(delta):
if Input.is_action_pressed("slow_down") and remaining_stamina > 0 :
ads = true
if !gamespeed_controlled:
Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, delta * 20)
Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, (delta * 50) / Engine.time_scale)
#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)
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, (delta * 100) / Engine.time_scale)
if remaining_stamina > 0:
remaining_stamina = clamp(remaining_stamina - ((delta * STAMINA_DRAIN)/Engine.time_scale),0,MAX_STAMINA)
remaining_stamina = clamp(remaining_stamina - ((delta * STAMINA_DRAIN) / Engine.time_scale),0,MAX_STAMINA)
else:
ads = false
if !gamespeed_controlled:
Engine.time_scale = lerp(Engine.time_scale, 1.0, delta * 50)
Engine.time_scale = lerp(Engine.time_scale, 1.0, (delta * 50)/Engine.time_scale)
#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/Engine.time_scale), 0, MAX_STAMINA)
@@ -448,11 +445,9 @@ func aim_down_sights(delta):
if gun:
if gun.ads == true:
if ads:
crosshair.visible = false
camera.fov -= .1
gun.position = lerp(gun.position,ADS_POS,delta * 10 / Engine.time_scale)
else:
crosshair.visible = true
gun.position = lerp(gun.position, weapon_start_pos,delta * 2)
func _headbob(time) -> Vector3:
@@ -583,6 +578,7 @@ func release_moveable():
moveable_holder.rotation = Vector3(0,0,0)
func hit(damage, fired_by, target_type):
SignalBus.emit_signal("player_hit")
level_control.health -= damage
level_control.last_hit = fired_by
level_control.target_type = target_type