Improved joystick support for camera (not perfect yet)

This commit is contained in:
Paul Black 2023-03-14 13:02:47 -06:00
parent d5c67fabbf
commit 6a215c7ced

View file

@ -48,20 +48,21 @@ func _unhandled_input(event):
neck.rotate_y(-event.relative.x * mousesense)
camera.rotate_x(-event.relative.y * mousesense)
## FOR CONTROLLERS
var cam_dir = Input.is_action_pressed("cam_left") or Input.is_action_pressed("cam_right") or Input.is_action_pressed("cam_up") or Input.is_action_pressed("cam_down")
if cam_dir:
var x = -event.relative.x * mousesense
var y = -event.relative.y * mousesense
if Input.is_action_pressed("cam_left"):
x -= 1 * mousesense
if Input.is_action_pressed("cam_right"):
x += 1 * mousesense
if Input.is_action_pressed("cam_up"):
y -= 1 * mousesense
if Input.is_action_pressed("cam_down"):
y += 1 * mousesense
neck.rotate_y(x)
camera.rotate_x(y)
if event is InputEventJoypadMotion:
var cam_dir = Input.is_action_pressed("cam_left") or Input.is_action_pressed("cam_right") or Input.is_action_pressed("cam_up") or Input.is_action_pressed("cam_down")
if cam_dir:
var x = -event.get_axis_value() * mousesense
var y = -event.get_axis_value() * mousesense
if Input.is_action_pressed("cam_left"):
x += 1 * mousesense
if Input.is_action_pressed("cam_right"):
x -= 1 * mousesense
if Input.is_action_pressed("cam_up"):
y += 1 * mousesense
if Input.is_action_pressed("cam_down"):
y -= 1 * mousesense
neck.rotate_y(x)
camera.rotate_x(y)
##################
# Clamps the camera