casings integrate player velocity, can't pick up already held guns

This commit is contained in:
derek
2024-11-05 16:58:00 -06:00
parent 83e2365892
commit c6f1eccca0
6 changed files with 49 additions and 45 deletions

View File

@@ -138,39 +138,12 @@ func _on_area_3d_body_part_hit(dam,bullet_damage):
func _on_prefire_timer_timeout():
#barrel 1 fire
var instance_bullet = bullet.instantiate()
instance_bullet.position = barrel_1.global_position
instance_bullet.transform.basis = barrel_1.global_transform.basis
instance_bullet.bullet_speed = bullet_speed
instance_bullet.bullet_drop = bullet_drop
instance_bullet.random_spread_amt = random_spread_amt
instance_bullet.bullet_damage = bullet_damage
instance_bullet.fired_by = self
get_tree().get_root().add_child(instance_bullet)
fire(barrel_1)
#barrel 2 fire
var instance_bullet2 = bullet.instantiate()
instance_bullet2.position = barrel_2.global_position
instance_bullet2.transform.basis = barrel_2.global_transform.basis
instance_bullet2.bullet_speed = bullet_speed
instance_bullet2.bullet_drop = bullet_drop
instance_bullet2.random_spread_amt = random_spread_amt
instance_bullet2.bullet_damage = bullet_damage
instance_bullet2.fired_by = self
get_tree().get_root().add_child(instance_bullet2)
fire(barrel_2)
turret_material.emission_enabled = false
var instance_casing = casing.instantiate()
instance_casing.position = casing_ejector.global_position
instance_casing.transform.basis = casing_ejector.global_transform.basis
var instance_casing2 = casing.instantiate()
instance_casing2.position = casing_ejector.global_position
instance_casing2.transform.basis = casing_ejector.global_transform.basis
get_tree().get_root().add_child(instance_casing)
get_tree().get_root().add_child(instance_casing2)
audio_fire.play()
prefire_timer.stop()
postfire_timer.start()
@@ -192,3 +165,22 @@ func _on_knocked_timer_timeout():
func _on_stunned_timer_timeout():
print("STUN TIMEOUT")
stunned = false
func fire(barrel):
var instance_bullet = bullet.instantiate()
instance_bullet.position = barrel.global_position
instance_bullet.transform.basis = barrel_1.global_transform.basis
instance_bullet.bullet_speed = bullet_speed
instance_bullet.bullet_drop = bullet_drop
instance_bullet.random_spread_amt = random_spread_amt
instance_bullet.bullet_damage = bullet_damage
instance_bullet.fired_by = self
get_tree().get_root().add_child(instance_bullet)
audio_fire.play()
spawn_casing()
func spawn_casing():
var instance_casing = casing.instantiate()
instance_casing.position = casing_ejector.global_position
instance_casing.transform.basis = casing_ejector.global_transform.basis
instance_casing.player_velocity = velocity * transform.basis