From 07583cd522491ebee42e6c7839ccc9b99a47d0f1 Mon Sep 17 00:00:00 2001 From: SyntaX Date: Sun, 24 Nov 2019 15:28:52 +0100 Subject: [PATCH] look around with controller --- WikiJam/Player/Player.gd | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/WikiJam/Player/Player.gd b/WikiJam/Player/Player.gd index e43cbe9..6fc2bf2 100644 --- a/WikiJam/Player/Player.gd +++ b/WikiJam/Player/Player.gd @@ -89,20 +89,23 @@ func _process_input(): if Input.is_action_pressed("move_right"): input_movement_vector.x += 1 + # look around with controller + var look = Vector2() + look.x = -Input.get_action_strength("cam_move_left") + Input.get_action_strength("cam_move_right") + look.y = +Input.get_action_strength("cam_move_down") - Input.get_action_strength("cam_move_up") + #Logger.info("look at: " + String(look)) + _camera.rotate_x(deg2rad(look.y * -1)) + self.rotate_y(deg2rad(look.x * -1)) + + # Prevent player from doing a purzelbaum + _camera.rotation_degrees.x = clamp(_camera.rotation_degrees.x, -70, 70) + # look around with mouse _dir = Vector3() var camera_transform = _camera.get_global_transform() _dir += -camera_transform.basis.z * input_movement_vector.y _dir += camera_transform.basis.x * input_movement_vector.x - # look around with controller - #var look = Vector2() - #look.x = -Input.get_action_strength("cam_move_left") + Input.get_action_strength("cam_move_right") - #look.y = +Input.get_action_strength("cam_move_down") - Input.get_action_strength("cam_move_up") - ##Logger.info("look at: " + String(look)) - ##Input.warp_mouse_position(look) - #look_at(Vector3(look.x, look.y, 1), Vector3.UP) - # jumping if Input.is_action_just_pressed("move_jump") and is_on_floor(): _vel.y = JUMP_SPEED