From 626d31d002614513fd8b4a9121842148cd16acbf Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:10:33 +0200 Subject: [PATCH 1/7] 2d movement click and move Changed it to use actions instead of the event, like in the sample --- tutorials/2d/2d_movement.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index 76c0f73ecd1..0f4a24da2d4 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -231,9 +231,9 @@ on the screen will cause the player to move to the target location. var target = position func _input(event): - if event is InputEventMouseButton: - if event.button_index == MOUSE_BUTTON_LEFT and event.pressed: - target = get_global_mouse_position() + #use is_action_just_pressed to only accept single taps as input + if event.is_action_pressed("click"): + target = get_global_mouse_position() func _physics_process(delta): velocity = position.direction_to(target) * speed From 199fb540efa92b22694b4b8f0ddfb21a59da11cc Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:16:24 +0200 Subject: [PATCH 2/7] 2d movement explicit drag --- tutorials/2d/2d_movement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index 0f4a24da2d4..6216d4039a1 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -231,7 +231,7 @@ on the screen will cause the player to move to the target location. var target = position func _input(event): - #use is_action_just_pressed to only accept single taps as input + #use is_action_just_pressed to only accept single taps as input instead of mouse drags if event.is_action_pressed("click"): target = get_global_mouse_position() From 5425bf6475e79d2acd9a8b16aaa9db73f52e9693 Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:42:54 +0200 Subject: [PATCH 3/7] 2d movement indent Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- tutorials/2d/2d_movement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index 6216d4039a1..c46cf179b2a 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -233,7 +233,7 @@ on the screen will cause the player to move to the target location. func _input(event): #use is_action_just_pressed to only accept single taps as input instead of mouse drags if event.is_action_pressed("click"): - target = get_global_mouse_position() + target = get_global_mouse_position() func _physics_process(delta): velocity = position.direction_to(target) * speed From 7154161fb5285834c1dc6644949cdbd34a779bfb Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:43:19 +0200 Subject: [PATCH 4/7] 2d movement click movement drag corrections Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- tutorials/2d/2d_movement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index c46cf179b2a..96b501a2a2e 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -231,7 +231,7 @@ on the screen will cause the player to move to the target location. var target = position func _input(event): - #use is_action_just_pressed to only accept single taps as input instead of mouse drags + # Use is_action_pressed to only accept single taps as input instead of mouse drags. if event.is_action_pressed("click"): target = get_global_mouse_position() From a81cc1b223853224c87c69ba07e3b9a88190eff2 Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Sun, 25 Aug 2024 17:55:18 +0200 Subject: [PATCH 5/7] 2d movement click move update cs --- tutorials/2d/2d_movement.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index 6216d4039a1..ee14b263911 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -254,12 +254,9 @@ on the screen will cause the player to move to the target location. public override void _Input(InputEvent @event) { - if (@event is InputEventMouseButton eventMouseButton) + if (Input.IsActionPressed("click")) { - if (eventMouseButton.ButtonIndex == MouseButton.Left && eventMouseButton.Pressed) - { - _target = GetGlobalMousePosition(); - } + _target = GetGlobalMousePosition(); } } From 59de1556d29bf4b0cf25c4f4fe9f4fcb5734c6f7 Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:28:37 +0200 Subject: [PATCH 6/7] 2d movement click cs StringName Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- tutorials/2d/2d_movement.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index 3315fa03752..db99a86c5cd 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -232,7 +232,7 @@ on the screen will cause the player to move to the target location. func _input(event): # Use is_action_pressed to only accept single taps as input instead of mouse drags. - if event.is_action_pressed("click"): + if event.is_action_pressed(&"click"): target = get_global_mouse_position() func _physics_process(delta): From 8a868a48086dafc55f3998bc849b6a6ff4ed5e99 Mon Sep 17 00:00:00 2001 From: HubbleCommand <39958198+HubbleCommand@users.noreply.github.com> Date: Mon, 26 Aug 2024 13:33:38 +0200 Subject: [PATCH 7/7] 2d movement cs event par Co-authored-by: Raul Santos --- tutorials/2d/2d_movement.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorials/2d/2d_movement.rst b/tutorials/2d/2d_movement.rst index db99a86c5cd..1f5da929bec 100644 --- a/tutorials/2d/2d_movement.rst +++ b/tutorials/2d/2d_movement.rst @@ -254,7 +254,8 @@ on the screen will cause the player to move to the target location. public override void _Input(InputEvent @event) { - if (Input.IsActionPressed("click")) + // Use IsActionPressed to only accept single taps as input instead of mouse drags. + if (@event.IsActionPressed("click")) { _target = GetGlobalMousePosition(); }