Skip to content

Commit 626d31d

Browse files
committed
2d movement click and move
Changed it to use actions instead of the event, like in the sample
1 parent 1508be4 commit 626d31d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tutorials/2d/2d_movement.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ on the screen will cause the player to move to the target location.
231231
var target = position
232232

233233
func _input(event):
234-
if event is InputEventMouseButton:
235-
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
236-
target = get_global_mouse_position()
234+
#use is_action_just_pressed to only accept single taps as input
235+
if event.is_action_pressed("click"):
236+
target = get_global_mouse_position()
237237

238238
func _physics_process(delta):
239239
velocity = position.direction_to(target) * speed

0 commit comments

Comments
 (0)