weapon pickup working

This commit is contained in:
derek
2024-07-16 14:54:35 -05:00
parent 2393c1e737
commit afe19d8848
21 changed files with 381 additions and 403 deletions

View File

@@ -229,6 +229,17 @@ func _on_pick_up_detection_body_entered(body):
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
pickup_sound.play()
body.queue_free()
elif body.pickupType == "weapon":
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
pickup_sound.play()
level_control.held_guns.append(body.gun_resource)
var instance_gun = body.gun_resource.instantiate()
level_control.ammo_current.append(instance_gun.max_ammo)
level_control.ammo_reserve.append(instance_gun.max_ammo * instance_gun.start_mags)
body.queue_free()
var weapon_id = level_control.held_guns.size() - 1
gun.anim_player.play("swap_out")
level_control.gun_spawn(weapon_id)
func _on_pick_up_magnet_body_entered(body):
@@ -259,5 +270,4 @@ func weapon_bob(vel : float, delta):
func weapon_recoil():
var recoil_to = camera.rotation.x + gun.recoil_amount
print(recoil_to)
camera.rotation.x = clamp(lerp(camera.rotation.x,recoil_to, .05), deg_to_rad(-90), deg_to_rad(60))