فهرست منبع

: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