started work on gun switching, need to iron out kinks and set up weapon management script
This commit is contained in:
@@ -32,6 +32,7 @@ var start_sensitivity
|
||||
@export var gun : Node
|
||||
|
||||
@onready var gun_ray = $Head/Camera3D/GunRay
|
||||
@onready var level_control = $".."
|
||||
|
||||
@onready var bullet_ray = $Head/Camera3D/BulletRay
|
||||
var instance_bullet
|
||||
@@ -64,16 +65,18 @@ var pickupmsg
|
||||
@onready var world_environment = $"../WorldEnvironment"
|
||||
@onready var pickup_sound = $Audio/PickupSound
|
||||
@onready var ear_wind = $Audio/EarWind
|
||||
@onready var weapon_spawner = $Head/Camera3D/WeaponHolder/WeaponSpawner
|
||||
|
||||
|
||||
func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
start_sensitivity = SENSITIVITY
|
||||
|
||||
#Set up gun variables
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
start_sensitivity = SENSITIVITY
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
|
||||
#turn off audio if unchecked in player
|
||||
@@ -181,6 +184,31 @@ func _physics_process(delta):
|
||||
gun.position = lerp(gun.position, gun.start_position,delta*7)
|
||||
gun_folded = false
|
||||
|
||||
#Weapon Swap Up
|
||||
if Input.is_action_just_pressed("scroll_up"):
|
||||
gun.queue_free()
|
||||
var instance_gun = level_control.gun_2.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
#Weapon Swap Down
|
||||
if Input.is_action_just_pressed("scroll_down"):
|
||||
gun.queue_free()
|
||||
var instance_gun = level_control.gun_1.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
|
||||
move_and_slide()
|
||||
weapon_tilt(input_dir.x, delta)
|
||||
weapon_sway(delta)
|
||||
@@ -226,7 +254,8 @@ func _on_pick_up_detection_body_entered(body):
|
||||
|
||||
func _on_pick_up_magnet_body_entered(body):
|
||||
if body.is_in_group("pickup"):
|
||||
print("pickup")
|
||||
var pickup_direction = self.global_position - body.global_position
|
||||
body.linear_velocity += pickup_direction * 5
|
||||
|
||||
func weapon_tilt(input_x, delta):
|
||||
if weapon_holder:
|
||||
|
||||
Reference in New Issue
Block a user