Improved controller camera again
This commit is contained in:
parent
6a215c7ced
commit
1cf3feb147
2 changed files with 21 additions and 14 deletions
|
@ -20,6 +20,8 @@ var menuOpen = false
|
||||||
var globalscene
|
var globalscene
|
||||||
var ranRemovePlayer = false
|
var ranRemovePlayer = false
|
||||||
var mousesense = Global.mouseSensitivity
|
var mousesense = Global.mouseSensitivity
|
||||||
|
var controllerAxisValue_x = 0
|
||||||
|
var controllerAxisValue_y = 0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
name = str(teddyAuthority)
|
name = str(teddyAuthority)
|
||||||
|
@ -51,18 +53,8 @@ func _unhandled_input(event):
|
||||||
if event is InputEventJoypadMotion:
|
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")
|
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:
|
if cam_dir:
|
||||||
var x = -event.get_axis_value() * mousesense
|
controllerAxisValue_x = -event.get_axis_value() * mousesense
|
||||||
var y = -event.get_axis_value() * mousesense
|
controllerAxisValue_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
|
# Clamps the camera
|
||||||
|
@ -116,6 +108,21 @@ func _physics_process(delta):
|
||||||
# Handle Jump.
|
# Handle Jump.
|
||||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||||
velocity.y = JUMP_VELOCITY
|
velocity.y = JUMP_VELOCITY
|
||||||
|
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:
|
||||||
|
if Input.is_action_pressed("cam_left"):
|
||||||
|
controllerAxisValue_x += 1 * mousesense
|
||||||
|
if Input.is_action_pressed("cam_right"):
|
||||||
|
controllerAxisValue_x -= 1 * mousesense
|
||||||
|
if Input.is_action_pressed("cam_up"):
|
||||||
|
controllerAxisValue_y += 1 * mousesense
|
||||||
|
if Input.is_action_pressed("cam_down"):
|
||||||
|
controllerAxisValue_y -= 1 * mousesense
|
||||||
|
neck.rotate_y(controllerAxisValue_x)
|
||||||
|
camera.rotate_x(controllerAxisValue_y)
|
||||||
|
else:
|
||||||
|
controllerAxisValue_x = 0
|
||||||
|
controllerAxisValue_y = 0
|
||||||
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
|
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
|
||||||
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
if input_dir:
|
if input_dir:
|
||||||
|
|
|
@ -64,7 +64,7 @@ sprint={
|
||||||
menu={
|
menu={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
shoot={
|
shoot={
|
||||||
|
@ -88,7 +88,7 @@ start_game={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194310,"key_label":0,"unicode":0,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194310,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
jump={
|
jump={
|
||||||
|
|
Loading…
Reference in a new issue