testing how branches work

This commit is contained in:
Derek
2024-07-14 17:45:23 -05:00
parent 9da31845b8
commit 13dd6f9a81
4 changed files with 42 additions and 41 deletions

View File

@@ -55,3 +55,44 @@ func _on_gun_anims_animation_finished(anim_name):
player.ammo += player.ammo_reserve
player.ammo_reserve -= player.ammo_reserve
player.reloading = false
func shoot():
if ammo > 0:
if !gun.anim_player.is_playing():
ammo -= 1
#RECOIL fix later to happen over a period of time
camera.rotation.x = clamp(lerp(camera.rotation.x, camera.rotation.x + gun.recoil_amount, delta * 10), deg_to_rad(-90), deg_to_rad(60))
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
gun.audio_fire.pitch_scale = 1 + rng.randf_range(-.2,.2)
gun.audio_fire.play()
gun.anim_player.play("shoot")
# shoot real bullet from camera
if gun_folded == false:
instance_bullet = gun.bullet.instantiate()
instance_bullet.position = bullet_ray.global_position
instance_bullet.transform.basis = bullet_ray.global_transform.basis
instance_bullet.bullet_speed = gun.bullet_speed
instance_bullet.bullet_drop = gun.bullet_drop
instance_bullet.random_spread_amt = gun.random_spread_amt
instance_bullet.gun = gun
get_parent().add_child(instance_bullet)
else:
instance_bullet = gun.bullet.instantiate()
instance_bullet.position = gun.barrel_raycast.global_position
instance_bullet.transform.basis = gun.barrel_raycast.global_transform.basis
instance_bullet.bullet_speed = gun.bullet_speed
instance_bullet.bullet_drop = gun.bullet_drop
instance_bullet.random_spread_amt = gun.random_spread_amt
instance_bullet.gun = gun
get_parent().add_child(instance_bullet)
# Casing transform
instance_casing = gun.casing.instantiate()
instance_casing.position = gun.casing_ejector.global_position
instance_casing.transform.basis = gun.casing_ejector.global_transform.basis
get_parent().add_child(instance_casing)
elif !gun.anim_player.is_playing():
gun.anim_player.play("empty")
gun.audio_empty.play()