From e54831e6160335dba6011fe7891cfa49d01b2774 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 24 Apr 2024 04:29:22 +0200 Subject: [PATCH] Make sure `MoveTowards` doesn't overshoot its target --- behaviours/move_towards.gd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/behaviours/move_towards.gd b/behaviours/move_towards.gd index 4dad3a0..68ec0be 100644 --- a/behaviours/move_towards.gd +++ b/behaviours/move_towards.gd @@ -32,7 +32,7 @@ func _physics_process(delta: float) -> void: if enabled: if target: var gap = target.global_position - global_position - var norm = gap.normalized() - move.emit(norm * delta * speed) + var norm = Vector2.ZERO.move_toward(gap, delta * speed) + move.emit(norm) else: move.emit(Vector2.ZERO)