From 6a215c7cedfbe71219a38b2d3df67f081bba6f1f Mon Sep 17 00:00:00 2001 From: Techwizz Date: Tue, 14 Mar 2023 13:02:47 -0600 Subject: [PATCH] Improved joystick support for camera (not perfect yet) --- characters/teddy/Teddy.gd | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/characters/teddy/Teddy.gd b/characters/teddy/Teddy.gd index a53409f..556a63d 100644 --- a/characters/teddy/Teddy.gd +++ b/characters/teddy/Teddy.gd @@ -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