File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff 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_pressed to only accept single taps as input instead of mouse drags.
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
@@ -254,12 +254,10 @@ on the screen will cause the player to move to the target location.
254254
255255 public override void _Input(InputEvent @event)
256256 {
257- if (@event is InputEventMouseButton eventMouseButton)
257+ // Use IsActionPressed to only accept single taps as input instead of mouse drags.
258+ if (@event.IsActionPressed("click"))
258259 {
259- if (eventMouseButton.ButtonIndex == MouseButton.Left && eventMouseButton.Pressed)
260- {
261- _target = GetGlobalMousePosition();
262- }
260+ _target = GetGlobalMousePosition();
263261 }
264262 }
265263
You can’t perform that action at this time.
0 commit comments