disable strafe with only keyboard

This commit is contained in:
AleaJactaEst 2022-02-03 20:46:03 +01:00
parent 09c4476938
commit 4608af0f80
2 changed files with 18 additions and 26 deletions

View file

@ -73,22 +73,19 @@ func _physics_process(delta):
input_dir = Input.get_vector("ui_right", "ui_left", "ui_down", "ui_up") input_dir = Input.get_vector("ui_right", "ui_left", "ui_down", "ui_up")
else: else:
var y = 0 var y = 0
if Input.is_action_pressed("ui_strafe_right") or Input.is_action_pressed("ui_strafe_left"): if Input.is_action_pressed("ui_right"):
input_dir = Input.get_vector("ui_strafe_right", "ui_strafe_left", "ui_down", "ui_up") y -= 1
else: if Input.is_action_pressed("ui_left"):
if Input.is_action_pressed("ui_right"): y += 1
y -= 1 if y != 0:
if Input.is_action_pressed("ui_left"): var dt = y * delta * speed_rotate_1sec
y += 1 camera_rotate_y += dt
if y != 0: if camera_rotate_y > PI:
var dt = y * delta * speed_rotate_1sec camera_rotate_y -= TWO_PI
camera_rotate_y += dt elif camera_rotate_y <= -PI:
if camera_rotate_y > PI: camera_rotate_y += TWO_PI
camera_rotate_y -= TWO_PI $camera_root/horizontal_root.rotate_y( dt )
elif camera_rotate_y <= -PI: input_dir = Input.get_vector("nothing", "nothing", "ui_down", "ui_up")
camera_rotate_y += TWO_PI
$camera_root/horizontal_root.rotate_y( dt )
input_dir = Input.get_vector("nothing", "nothing", "ui_down", "ui_up")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction: if direction:

View file

@ -45,18 +45,13 @@ ui_down={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
] ]
} }
ui_strafe_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":true,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)
]
}
ui_strafe_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":true,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null)
]
}
ui_strafe={ ui_strafe={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
] ]
} }
move_run={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"meta_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":16777237,"unicode":0,"echo":false,"script":null)
]
}