1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 23:54:23 +00:00

Make sure MoveTowards doesn't overshoot its target

This commit is contained in:
Steffo 2024-04-24 04:29:22 +02:00
parent 70bc60a8e8
commit e54831e616
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -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)