From 4bbb4b9a19b1e14acf252e8c61cca21ce9c18a9a Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 15 Feb 2021 11:00:49 -0500 Subject: [PATCH] Reorder NaN check --- core/src/mindustry/ai/types/LogicAI.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/ai/types/LogicAI.java b/core/src/mindustry/ai/types/LogicAI.java index c910999c2f..5f72520729 100644 --- a/core/src/mindustry/ai/types/LogicAI.java +++ b/core/src/mindustry/ai/types/LogicAI.java @@ -119,9 +119,6 @@ public class LogicAI extends AIController{ vec.set(target).sub(unit); - //do not move when infinite vectors are used. - if(vec.isNaN() || vec.isInfinite()) return; - float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / smooth, -1f, 1f); vec.setLength(unit.realSpeed() * length); @@ -131,6 +128,9 @@ public class LogicAI extends AIController{ vec.setZero(); } + //do not move when infinite vectors are used. + if(vec.isNaN() || vec.isInfinite()) return; + unit.approach(vec); }