// Update is called once per frame void Update() { if (visionConeBehaviour.hasVisibleTargets()) { GameObject closestTarget = visionConeBehaviour.getClosestVisibleTarget(); Vector3 directionToTarget = closestTarget.transform.position - this.transform.position; float distanceToTarget = directionToTarget.magnitude; if (distanceToTarget > 3) { directionVector = directionToTarget.normalized; } } base.Update(); }