From 0aa8caa4b25b502f3361cb516c52d3981b3907ca Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sat, 5 Feb 2022 02:06:50 +0100 Subject: [PATCH] adding automove with option to disable if forward/backward/automove is pressed --- player/player.gd | 10 +++++++++- project.godot | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/player/player.gd b/player/player.gd index c7382e5..deedb02 100644 --- a/player/player.gd +++ b/player/player.gd @@ -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: diff --git a/project.godot b/project.godot index 781aee1..a562d02 100644 --- a/project.godot +++ b/project.godot @@ -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) +] +}