feat: implement projectile system and add nail gun, plasma gun, and DMR weapons
This commit is contained in:
@@ -110,3 +110,9 @@ func _input(event: InputEvent) -> void:
|
|||||||
func _start_reload() -> void:
|
func _start_reload() -> void:
|
||||||
super._start_reload()
|
super._start_reload()
|
||||||
is_ads = false # Drop out of ADS on 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
@@ -105,13 +105,14 @@ func _spawn_custom_projectile(origin: Vector3, fire_dir: Vector3) -> void:
|
|||||||
proj.add_child(mesh_instance)
|
proj.add_child(mesh_instance)
|
||||||
|
|
||||||
# Projectile rotation so it faces velocity
|
# Projectile rotation so it faces velocity
|
||||||
# (Basis looking towards fire_dir)
|
var up_vec = Vector3.UP
|
||||||
var up = Vector3.UP
|
if abs(fire_dir.dot(up_vec)) > 0.99:
|
||||||
if abs(fire_dir.dot(up)) > 0.99:
|
up_vec = Vector3.RIGHT
|
||||||
up = Vector3.RIGHT
|
proj.transform.basis = Basis.looking_at(fire_dir, up_vec)
|
||||||
proj.transform.basis = Basis.looking_at(fire_dir, up)
|
|
||||||
|
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.velocity = fire_dir * projectile_speed
|
||||||
proj.damage = base_damage
|
proj.damage = base_damage
|
||||||
proj.min_damage = min_damage
|
proj.min_damage = min_damage
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ func _spawn_custom_projectile(origin: Vector3, fire_dir: Vector3) -> void:
|
|||||||
light.omni_range = 4.0
|
light.omni_range = 4.0
|
||||||
proj.add_child(light)
|
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.velocity = fire_dir * projectile_speed
|
||||||
proj.damage = base_damage
|
proj.damage = base_damage
|
||||||
proj.min_damage = min_damage
|
proj.min_damage = min_damage
|
||||||
|
|||||||
@@ -10,9 +10,13 @@ var falloff_start: float = 10.0
|
|||||||
var min_damage: float = 5.0
|
var min_damage: float = 5.0
|
||||||
var drop_gravity: float = 0.0 # For arc projectiles (nailgun might have slight drop, plasma none)
|
var drop_gravity: float = 0.0 # For arc projectiles (nailgun might have slight drop, plasma none)
|
||||||
|
|
||||||
|
var logical_source = null
|
||||||
var _previous_position: Vector3
|
var _previous_position: Vector3
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
if logical_source != null:
|
||||||
|
_previous_position = logical_source
|
||||||
|
else:
|
||||||
_previous_position = global_position
|
_previous_position = global_position
|
||||||
# Automatically destroy after 5 seconds to prevent leaks
|
# Automatically destroy after 5 seconds to prevent leaks
|
||||||
var t = get_tree().create_timer(5.0)
|
var t = get_tree().create_timer(5.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user