23 lines
699 B
GDScript
23 lines
699 B
GDScript
extends Node3D
|
|
|
|
var recoil_amount : Vector3 = Vector3(.1,0,0)
|
|
var snap_amount : float = 8
|
|
var speed : float = 4
|
|
var current_rotation : Vector3
|
|
var target_rotation : Vector3
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
target_rotation = lerp(target_rotation, Vector3.ZERO, speed * delta)
|
|
current_rotation = lerp(current_rotation, target_rotation, snap_amount * delta)
|
|
basis = Quaternion.from_euler(current_rotation)
|
|
|
|
func add_recoil() -> void:
|
|
print("ADD RECOIL")
|
|
target_rotation += Vector3(.1,0,0)
|