feat: implement projectile system and add nail gun, plasma gun, and DMR weapons

This commit is contained in:
DottsGit
2026-06-04 17:35:12 -04:00
parent 7b7107c5d6
commit c32f45a8aa
4 changed files with 21 additions and 8 deletions
+6
View File
@@ -110,3 +110,9 @@ func _input(event: InputEvent) -> void:
func _start_reload() -> void:
super._start_reload()
is_ads = false # Drop out of ADS on reload
func unequip() -> void:
is_ads = false
if camera:
camera.fov = default_fov
position = Vector3(0.3, -0.3, -0.7)
+7 -6
View File
@@ -105,13 +105,14 @@ func _spawn_custom_projectile(origin: Vector3, fire_dir: Vector3) -> void:
proj.add_child(mesh_instance)
# Projectile rotation so it faces velocity
# (Basis looking towards fire_dir)
var up = Vector3.UP
if abs(fire_dir.dot(up)) > 0.99:
up = Vector3.RIGHT
proj.transform.basis = Basis.looking_at(fire_dir, up)
var up_vec = Vector3.UP
if abs(fire_dir.dot(up_vec)) > 0.99:
up_vec = Vector3.RIGHT
proj.transform.basis = Basis.looking_at(fire_dir, up_vec)
proj.position = muzzle_flash.global_position if muzzle_flash else origin
proj.logical_source = origin
proj.global_position = muzzle_flash.global_position if muzzle_flash else origin
proj.velocity = fire_dir * projectile_speed
proj.damage = base_damage
proj.min_damage = min_damage
+3 -1
View File
@@ -90,7 +90,9 @@ func _spawn_custom_projectile(origin: Vector3, fire_dir: Vector3) -> void:
light.omni_range = 4.0
proj.add_child(light)
proj.global_position = muzzle_flash.global_position if muzzle_flash else origin
proj.position = muzzle_flash.global_position if muzzle_flash else origin
proj.logical_source = origin
proj.velocity = fire_dir * projectile_speed
proj.damage = base_damage
proj.min_damage = min_damage
+4
View File
@@ -10,9 +10,13 @@ var falloff_start: float = 10.0
var min_damage: float = 5.0
var drop_gravity: float = 0.0 # For arc projectiles (nailgun might have slight drop, plasma none)
var logical_source = null
var _previous_position: Vector3
func _ready() -> void:
if logical_source != null:
_previous_position = logical_source
else:
_previous_position = global_position
# Automatically destroy after 5 seconds to prevent leaks
var t = get_tree().create_timer(5.0)