Hi there. I've got a problem.
I'm attempting to fix this "glitch"/"twitching" of the camera when rotated by this script:
onready var Head = $Head
onready var Eyes = $Head/Camera
var camera_angle = 0
# var camera_fov = 90
var camera_min_y = -90
var camera_max_y = 90
var mouse_sensitivity = 0.5
var mouse_drag_x = 0.4
var mouse_drag_y = 0.6
if event is InputEventMouseMotion:
var camera_movement_horizontal = -event.relative.x * mouse_sensitivity * mouse_drag_x
var camera_movement_vertical = -event.relative.y * mouse_sensitivity * mouse_drag_y
if camera_movement_vertical + camera_angle < camera_max_y and camera_movement_vertical + camera_angle > camera_min_y:
camera_angle += camera_movement_vertical
Eyes.rotation_degrees.x = camera_max_y if camera_movement_vertical > 0 else camera_min_y
It works enough for a camera to rotate and respect its boundaries but if done quickly up and down it starts to snap at -90 and 90 degrees.
Is there a fix for that?
PS. The Godots FPS tutorial suffers the same snap effect if MOUSE_SENSITIVITY is sped up (like 0.3 or more).
PS. Code inspired by First Person Controller Tutorial by Jeremy Bullock
PS. Im still learning both the engine and the eng lang. O' right?