Advertisement
Ragdev

Weaponsway Script

Apr 16th, 2024 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Node3D
  2.  
  3. var mouse_move
  4. var sway_threshold = 5
  5. var sway_lerp = 5
  6.  
  7. @export var sway_left: Vector3
  8. @export var sway_right: Vector3
  9. @export var sway_normal: Vector3
  10.  
  11. func _input(event):
  12.     if event is InputEventMouseMotion:
  13.         mouse_move = -event.relative.x
  14.  
  15. func _process(delta):
  16.     if mouse_move != null:
  17.         if mouse_move > sway_threshold:
  18.             rotation = rotation.lerp(sway_left, sway_lerp * delta)
  19.         elif mouse_move < -sway_threshold:
  20.             rotation = rotation.lerp(sway_right, sway_lerp * delta)
  21.         else:
  22.             rotation = rotation.lerp(sway_normal, sway_lerp * delta)
Tags: Godot fps 3D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement