Now the movement keys are bindable.

This commit is contained in:
Relintai 2020-07-27 18:47:40 +02:00
parent 92ae39d933
commit 59d57669fa
2 changed files with 39 additions and 12 deletions

View File

@ -420,17 +420,23 @@ func _input(event: InputEvent) -> void:
camera_pivot.rotate_delta(-relx, -rely)
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventKey:
var ievkey : InputEventKey = event as InputEventKey
if ievkey.scancode == KEY_W:
key_up = ievkey.pressed
if ievkey.scancode == KEY_S:
key_down = ievkey.pressed
if ievkey.scancode == KEY_A:
key_left = ievkey.pressed
if ievkey.scancode == KEY_D:
key_right = ievkey.pressed
if event.is_action_type():
if event.is_action("move_forward"):
key_up = event.pressed
get_tree().set_input_as_handled()
return
elif event.is_action("move_backward"):
key_down = event.pressed
get_tree().set_input_as_handled()
return
elif event.is_action("move_left"):
key_left = event.pressed
get_tree().set_input_as_handled()
return
elif event.is_action("move_right"):
key_right = event.pressed
get_tree().set_input_as_handled()
return
if event is InputEventMouseMotion and not (mouse_right_down or mouse_left_down) and event.device != -1:
cmouseover(event)
@ -464,10 +470,11 @@ func _unhandled_input(event: InputEvent) -> void:
if not event.pressed and event.button_index == BUTTON_LEFT and event.device != -1:
if mouse_down_delta.length() < MOUSE_TARGET_MAX_OFFSET:
target(event.position)
if event is InputEventScreenTouch and event.pressed:
target(event.position)
update_cursor_mode()
func update_cursor_mode():

View File

@ -325,6 +325,26 @@ sheath={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
]
}
move_forward={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
}
move_backward={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}
[layer_names]