瀏覽代碼

:wrench: Make mouse motion move the player as well

Like mouse click.
DricomDragon 2 年之前
父節點
當前提交
689eac0c1d
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      godot/Player.gd

+ 4 - 1
godot/Player.gd

@@ -45,7 +45,7 @@ func _process(delta):
 
 
 func _input(event):
-	if event is InputEventMouseButton:
+	if event is InputEventMouseButton or event is InputEventMouseMotion :
 		target = event.position
 		target_reached = false
 
@@ -72,8 +72,11 @@ func get_velocity_from_action() -> Vector2:
 func get_velocity_from_target(delta):
 	if target_reached :
 		return Vector2.ZERO
+
 	var path = target - position
+
 	if path.length_squared() < speed * speed * delta * delta :
 		target_reached = true
+		return Vector2.ZERO
 
 	return path