fixed the recoil jiggle

This commit is contained in:
derek
2024-11-06 14:38:15 -06:00
parent d86efbb357
commit fc00ce0fb2
3 changed files with 6 additions and 7 deletions

View File

@@ -5,7 +5,6 @@ var speed : float = 10
var current_rotation : Vector3
var target_rotation : Vector3
var head_current_rotation : float
var gun_recoil_target_rotation : float = 0
var gun_recoil
@@ -24,11 +23,11 @@ func _process(delta: float) -> void:
basis = Quaternion.from_euler(current_rotation)
#Handle Gun Recoil
head_current_rotation = lerp(head_current_rotation, gun_recoil_target_rotation, delta * 10)
gun_recoil = lerp(head_current_rotation,gun_recoil_target_rotation, delta * snap_amount)
gun_recoil = lerp(0.0,gun_recoil_target_rotation, delta * 30)
head.rotation.x = clamp(head.rotation.x + gun_recoil, deg_to_rad(-90), deg_to_rad(85))
gun_recoil_target_rotation -= gun_recoil
func add_recoil(recoil_amount,snap_change,speed_change) -> void:
#set to provided snap/speed changes
snap_amount = snap_change