look around with controller

This commit is contained in:
SyntaX 2019-11-24 15:28:52 +01:00
parent f5e7305d01
commit 07583cd522

View File

@ -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