Hey, I am currently working on a game with a first person view and trying to have both mouse and keyboard as well as controller support working. Aiming with the mouse works great, but when I try to aim using the right joystick on a controller (I tried both an Xbox and a PS4 controller) the rotation of the view is stuttering.
I have a simple set up where I rotate the player's "head" based on the input.
Here is the code I have in the _input function that I use to detect whether i'm using a controller or a mouse.
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
rotate_y(deg_to_rad(event.relative.x * mouse_horizontal_look_sensitivity) * invert_horizontal_mouse_look)
head.rotate_x(deg_to_rad(event.relative.y * mouse_vertical_look_sensitivity) * invert_vertical_mouse_look)
if event is InputEventJoypadMotion:
look_direction = Input.get_vector("look_left","look_right","look_up","look_down")
rotate_y(deg_to_rad(look_direction.x * joypad_horizontal_look_sensitivity * invert_horizontal_joypad_look))
head.rotate_x(deg_to_rad(look_direction.y * joypad_vertical_look_sensitivity * invert_vertical_joypad_look))
head.rotation.x = clamp(head.rotation.x,deg_to_rad(-89),deg_to_rad(89))
Also attached a video.