瀏覽代碼

2d movement click move update cs

HubbleCommand 1 年之前
父節點
當前提交
a81cc1b223
共有 1 個文件被更改,包括 2 次插入5 次删除
  1. 2 5
      tutorials/2d/2d_movement.rst

+ 2 - 5
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();
             }
         }