Vector pursueEntity(AIEntity entityToCatch) { Vector targetPos = entityToCatch.getPosition() - this.owner.getPosition(); double relativeHead = owner.getHeadingDirection().dotProduct(entityToCatch.getHeadingDirection()); if(targetPos.dotProduct(owner.getHeadingDirection()) > 0 && relativeHead < -0.9) { return this.seek(entityToCatch.getPosition()); } double lookAhead = Math.sqrt(vecToTarg.lengthSquared()) / (owner.getMaxSpeed() + Math.sqrt(entityToCatch.currentSpeedSquared())); return this.seek(entityToCatch.getPosition() + (entityToCatch.getVelocity() * lookAhead)); }