Skip to content

Commit 67acb3b

Browse files
committed
hotfix
1 parent fbbc503 commit 67acb3b

File tree

1 file changed

+3
-2
lines changed
  • src/main/java/dev/zwazel/internal/game/tank

1 file changed

+3
-2
lines changed

src/main/java/dev/zwazel/internal/game/tank/Tank.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,19 @@ default void moveTowards(PublicGameWorld world, MoveDirection moveDirection, Vec
7474
double currentYaw = currentForward.getAngle();
7575
double desiredYaw = horizontalToTarget.getAngle();
7676
double deltaYaw = Math.atan2(Math.sin(desiredYaw - currentYaw), Math.cos(desiredYaw - currentYaw));
77+
double distanceToTarget = targetPosition.distance(currentPos);
7778

7879
// If we move simultaneously, rotate and move in this call
7980
if (simultaneous) {
8081
rotateBody(world, deltaYaw);
81-
move(world, moveDirection);
82+
move(world, moveDirection, distanceToTarget);
8283
} else {
8384
// Only move if we're facing mostly toward the target
8485
double angleThreshold = 0.1; // adjust as needed
8586
if (Math.abs(deltaYaw) > angleThreshold) {
8687
rotateBody(world, deltaYaw);
8788
} else {
88-
move(world, moveDirection);
89+
move(world, moveDirection, distanceToTarget);
8990
}
9091
}
9192
}

0 commit comments

Comments
 (0)