From 4c7e428bfba5361907e2d2f2d5fcad51ce6af404 Mon Sep 17 00:00:00 2001 From: vinceh121 Date: Thu, 21 Sep 2023 15:03:20 +0200 Subject: [PATCH] fix: guntower ai angle and rotation --- .../wanderer/guntower/GuntowerAiController.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/me/vinceh121/wanderer/guntower/GuntowerAiController.java b/core/src/me/vinceh121/wanderer/guntower/GuntowerAiController.java index 49d3d32..5ddfa49 100644 --- a/core/src/me/vinceh121/wanderer/guntower/GuntowerAiController.java +++ b/core/src/me/vinceh121/wanderer/guntower/GuntowerAiController.java @@ -40,14 +40,9 @@ public void tick(float delta) { .cpy() .sub(this.target.getTranslation().add(0, this.target.getAverageTurretPosition().y, 0)) .nor(); - final float angle = this.target.getLookDirection().dot(closestDir); - if (MathUtils.isEqual(angle, 1f, 0.3f)) { - this.target.fire(); - } - -// final Vector3 newDir = this.target.getLookDirection().slerp(closestDir, this.turnSpeed * delta); - Vector3 newDir = closestDir.cpy(); + final Vector3 newDir = this.target.getLookDirection().slerp(closestDir, delta); +// Vector3 newDir = closestDir.cpy(); newDir.rotateRad(Vector3.X, MathUtils.HALF_PI); final float polar = MathUtilsW.getSphericalPolar(newDir.z); @@ -55,5 +50,11 @@ public void tick(float delta) { this.target.setPolarAngle(1 - (polar / MathUtils.PI)); this.target.setAzimuth(1 - (azimuth / MathUtils.PI2)); + + final float angle = this.target.getLookDirection().dot(closestDir); + + if (MathUtils.isEqual(angle, 1f, 0.1f)) { + this.target.fire(); + } } }