tweaked crouch slide

This commit is contained in:
derek
2024-12-09 14:18:43 -06:00
parent a1518945d4
commit fee4abaa9d
7 changed files with 68 additions and 51 deletions

View File

@@ -71,14 +71,18 @@ func _process(delta: float) -> void:
stam_bar_visible = true
current_stam_bar.value = player.remaining_stamina
ammo.text = str(level_control.ammo_current[level_control.current_gun_index]) +" | " + str(level_control.ammo_reserve[level_control.current_gun_index])
if player.gun != null:
ammo.text = str(level_control.ammo_current[level_control.current_gun_index]) +" | " + str(level_control.ammo_reserve[level_control.current_gun_index])
lerp_color(ammo,RED_COLOR,FULL_WHITE,level_control.ammo_current[level_control.current_gun_index],player.gun.max_ammo,.5)
else:
fade_in_out(ammo,1,false,10,delta)
fade_in_out(crosshair,1,false,10,delta)
if player.gun != null:
gun_name.text = player.gun.gun_name
else:
gun_name.visible = false
lerp_color(ammo,RED_COLOR,FULL_WHITE,level_control.ammo_current[level_control.current_gun_index],player.gun.max_ammo,.5)
if player.remaining_stamina < 25:
change_color(current_stam_bar,RED_COLOR,10,delta)

View File

@@ -15,6 +15,7 @@ const STAND_POS = Vector3(0,0.889,0)
const SLOWSPEED = .1
const MAX_STAMINA : float = 100
const STAMINA_DRAIN = 20
const HEAD_TILT_AMT = .06
const BOB_FREQ = 1.7
const BOB_AMP = 0.1
const ADS_POS = Vector3(0,-.05,-.45)
@@ -228,10 +229,11 @@ func _physics_process(delta):
else:
crouched = !crouched
recoil.add_recoil(Vector3(.2,0,0),5,10)
crouch_audio.play()
velocity.y -= 15
if is_on_floor():
crouch_audio.play()
velocity += direction * 20
else:
velocity.y -= 15
#walking
if is_on_floor() and !is_climbing:
@@ -454,8 +456,10 @@ func _headbob(time) -> Vector3:
var pos = Vector3.ZERO
pos.y = sin(time * BOB_FREQ) * BOB_AMP
pos.x = cos(time * BOB_FREQ / 2) * BOB_AMP
if pos.y >= .07 and is_on_floor() and velocity.length() >= 1 and !footstep_sound.is_playing():
footstep_sound.play()
return pos
@@ -485,7 +489,7 @@ func weapon_tilt(input_x, delta):
if weapon_holder:
weapon_holder.rotation.z = lerp(weapon_holder.rotation.z, -input_x * weapon_rotation_amount * 10, 4 * delta)
if camera:
camera.rotation.z = lerp(camera.rotation.z, -input_x * .075, 5 * delta)
camera.rotation.z = lerp(camera.rotation.z, -input_x * HEAD_TILT_AMT, 5 * delta)
func weapon_sway(delta):
if !ads:

View File

@@ -29,7 +29,8 @@ func picked_up():
level_control.ammo_current.append(instance_gun.max_ammo)
level_control.ammo_reserve.append(instance_gun.max_ammo * instance_gun.start_mags)
var weapon_id = level_control.held_guns.size() - 1
level_control.player.gun.anim_player.play("swap_out")
if level_control.player.gun != null:
level_control.player.gun.anim_player.play("swap_out")
level_control.gun_spawn(weapon_id)
queue_free()