diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index a44b5b457c..b7054442a6 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -405,8 +405,8 @@ public class CommandAI extends AIController{ } public void commandPosition(Vec2 pos, boolean stopWhenInRange){ - targetPos = pos; - lastTargetPos = pos; + //this is an allocation, but it's relatively rarely called anyway, and outside mutations must be prevented + targetPos = lastTargetPos = pos.cpy(); attackTarget = null; pathId = Vars.controlPath.nextTargetId(); this.stopWhenInRange = stopWhenInRange;