Godot Version
4.5-beta3
Question
Hi everyone! I have a simple FPS character using a Dualschock5 controller for input. Reading the input for movement works smoothly but something weird is going on when I rotate the character with the right stick. I’d love to know what is causing it.
Here’s the code and a link to a video of the issue. Thank you in advance!
func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
var input = Input.get_vector("look_right", "look_left", "look_down", "look_up")
rotate_y(input.x * look_sensitivity)
$Camera3D.rotate_x(input.y * look_sensitivity)
$Camera3D.rotation.x = clampf($Camera3D.rotation.x, -deg_to_rad(70), deg_to_rad(70))
if event.is_action_pressed("shoot"):
shoot()
if event is InputEventMouseButton:
if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
get_viewport().set_input_as_handled()
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * mouse_sensitivity)
$Camera3D.rotate_x(-event.relative.y * mouse_sensitivity)
$Camera3D.rotation.x = clampf($Camera3D.rotation.x, -deg_to_rad(70), deg_to_rad(70))