adding automove with option to disable if forward/backward/automove is pressed

This commit is contained in:
AleaJactaEst 2022-02-05 02:06:50 +01:00
parent 2899e4b521
commit 0aa8caa4b2
2 changed files with 15 additions and 2 deletions

View file

@ -48,6 +48,7 @@ var anim_walk:String = "CHAR_walk"
var anim_walk_backward:String = "CHAR_walk_backward"
var current_anim:String = anim_idle
var player_sit:bool = false
var player_automove:bool = false
func search_animation( obj:Node , root:String = "/") -> bool:
@ -121,8 +122,10 @@ func _input(event):
else:
var zoom3D:Vector3 = Vector3(0.0, ZOOM_STEP_Y, ZOOM_STEP_Z)
$camera_root/horizontal_root/vertical_root/Camera3D_TPS.translate_object_local(zoom3D)
elif Input.is_action_just_pressed("sit"):
elif Input.is_action_just_pressed("player_sit"):
player_sit = not player_sit
elif Input.is_action_just_pressed("player_automove"):
player_automove = not player_automove
# If right mouse button is pressed and mouse moves, pan horizontally camera
# and rotate vertically
@ -221,9 +224,14 @@ func _physics_process(delta):
if Input.is_action_pressed("ui_up"):
input_y = 1.0
move_up = true
player_automove = false
elif Input.is_action_pressed("ui_down"):
player_automove = false
input_y = -1.0
move_down = true
elif player_automove:
input_y = 1.0
move_up = true
if is_run:
if move_strafe:

View file

@ -65,8 +65,13 @@ camera_zoom_out={
"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":5,"pressed":false,"double_click":false,"script":null)
]
}
sit={
player_sit={
"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":88,"physical_keycode":0,"unicode":120,"echo":false,"script":null)
]
}
player_automove={
"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":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
]
}