Seems more reliable than the original method but not perfect. Added number based weapon switching

This commit is contained in:
derek
2024-10-29 17:00:46 -05:00
parent 00aa8db85d
commit 7c32586348
5 changed files with 62 additions and 5 deletions

View File

@@ -211,7 +211,7 @@ func _physics_process(delta):
#Land Sound
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
var land_volume = clamp( moving_fast_top_speed - 20 ,-10,0)
var recoil_amount = Vector3(-.1,0,0)
var recoil_amount = Vector3(-.3,0,0)
land_sound.volume_db = land_volume
land_sound.play()
recoil.add_recoil(recoil_amount,10,2)
@@ -284,6 +284,36 @@ func _physics_process(delta):
gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index - 1)
# Weapon Swap Number 1
if Input.is_action_just_pressed("numb_1") and !gun.anim_player.is_playing():
var gun_id = 0
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_2") and !gun.anim_player.is_playing():
var gun_id = 1
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_3") and !gun.anim_player.is_playing():
var gun_id = 2
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_4") and !gun.anim_player.is_playing():
var gun_id = 3
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_5") and !gun.anim_player.is_playing():
var gun_id = 4
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
#interact button
if Input.is_action_just_pressed("interact"):