moved key gun functions into gun script. small glitch in reload animation that I havent diagnosed yet

This commit is contained in:
Derek
2024-07-14 19:04:53 -05:00
parent db3b4fdbdc
commit b9001901df
6 changed files with 691 additions and 42 deletions

View File

@@ -152,26 +152,14 @@ func _physics_process(delta):
# Reloading
if Input.is_action_just_pressed("reload"):
if ammo < gun.max_ammo and reloading == false and ammo_reserve > 0:
reloading = true
gun.anim_player.play("reload")
gun.audio_reload.play()
instance_mag = gun.mag.instantiate()
await get_tree().create_timer(.28).timeout
instance_mag.position = gun.mag_ejector.global_position
instance_mag.transform.basis = gun.mag_ejector.global_transform.basis
get_parent().add_child(instance_mag)
if gun.anim_player.is_playing() and gun.anim_player.current_animation == "reload":
if ammo == 0:
ammo = 0
else:
ammo = 1
gun.reload(self,delta)
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
gun.anim_player.play("inspect")
# Shooting
if Input.is_action_pressed("shoot"):
gun.shoot(self,bullet_ray,delta)
gun.shoot(self,delta)
@@ -239,8 +227,8 @@ func weapon_tilt(input_x, delta):
func weapon_sway(delta):
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 10 * delta)
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 10 * delta)
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 1 * delta)
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 1 * delta)
#crosshair.position.x = lerp(crosshair.position.x, mouse_input.x * 100, 2 * delta)