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

@@ -21,7 +21,7 @@ var player_velocity
func _ready():
visible = false
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -31,7 +31,7 @@ func _physics_process(delta):
distance_from_player = abs(self.global_position - player_position)
if distance_from_player.x > 2 or distance_from_player.y > 2 or distance_from_player.z > 2:
if distance_from_player.length() > 1.5:
visible = true

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"):

View File

@@ -14,7 +14,7 @@ var player_position
# Called when the node enters the scene tree for the first time.
func _ready():
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
blast_radius = radius_shape.shape.radius
# Called every frame. 'delta' is the elapsed time since the previous frame.