Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | turtilla955 |
here is all the code
var mouse_mov_x
var mouse_mov_y
var sway_threshold = 1.2
var sway_lerp = 5
var can_sway = true
@export var sway_left : Vector3
@export var sway_right : Vector3
@export var sway_normal : Vector3
@export var sway_up : Vector3
@export var sway_down : Vector3
func _input(event):
if event is InputEventMouseMotion:
mouse_mov_x = -event.relative.x
mouse_mov_y = -event.relative.y
func _process(delta):
if mouse_mov_x != null and can_sway == true:
if mouse_mov_x > sway_threshold:
rotation = rotation.lerp(sway_left, sway_lerp * delta)
elif mouse_mov_x < -sway_threshold:
rotation = rotation.lerp(sway_right, sway_lerp * delta)
else:
rotation = rotation.lerp(sway_normal, sway_lerp * delta)
#this is the part that does not work:
if mouse_mov_y != null and can_sway == true:
if mouse_mov_y > sway_threshold:
rotation = rotation.lerp(sway_up, sway_lerp * delta)
elif mouse_mov_y < -sway_threshold:
rotation = rotation.lerp(sway_down, sway_lerp * delta)
else:
rotation = rotation.lerp(sway_normal, sway_lerp * delta)
one axis does work but the other does not, how can i fix this?