feat: implement WeaponManager with viewport-based viewmodel rendering and procedural animation support

This commit is contained in:
DottsGit
2026-06-09 22:44:56 -04:00
parent 3e6eb40add
commit cff83b6356
+10
View File
@@ -60,6 +60,7 @@ var _recoil_pitch: float = 0.0
var _recoil_yaw: float = 0.0 var _recoil_yaw: float = 0.0
var _target_drift_offset: Vector3 = Vector3.ZERO var _target_drift_offset: Vector3 = Vector3.ZERO
var _current_drift_offset: Vector3 = Vector3.ZERO var _current_drift_offset: Vector3 = Vector3.ZERO
var _swap_pitch: float = 0.0
func add_recoil(pitch: float, yaw: float) -> void: func add_recoil(pitch: float, yaw: float) -> void:
_recoil_pitch += pitch * 20.0 # Scale up for visual model recoil _recoil_pitch += pitch * 20.0 # Scale up for visual model recoil
@@ -116,6 +117,12 @@ func _process(_delta: float) -> void:
# Add a slight backward kick along the local Z axis # Add a slight backward kick along the local Z axis
vm_camera.translate_object_local(Vector3(0, 0, _recoil_pitch * 0.01)) vm_camera.translate_object_local(Vector3(0, 0, _recoil_pitch * 0.01))
# Swap Animation
_swap_pitch = lerpf(_swap_pitch, 0.0, 15.0 * _delta)
if _swap_pitch > 0.1:
vm_camera.rotate_object_local(Vector3.RIGHT, deg_to_rad(_swap_pitch))
vm_camera.translate_object_local(Vector3(0, -_swap_pitch * 0.005, 0))
vm_camera.fov = lerpf(vm_camera.fov, target_fov, 10.0 * _delta) vm_camera.fov = lerpf(vm_camera.fov, target_fov, 10.0 * _delta)
func _build_loadout() -> void: func _build_loadout() -> void:
@@ -269,6 +276,9 @@ func _equip_slot(slot: int) -> void:
if w.has_method("unequip"): if w.has_method("unequip"):
w.unequip() w.unequip()
if active_slot != slot:
_swap_pitch = 60.0
active_slot = slot active_slot = slot
if weapons.has(active_slot): if weapons.has(active_slot):