private void FixedUpdate() { if ((Vision() || Hearing())) { memoryTimer = targetMemoryTime; detectsTarget = true; } else { if (memoryTimer <= 0) { if (targetTransform != null) { detectsTarget = false; targetTransform = null; } } else { memoryTimer -= Time.deltaTime; } } if (isUsingAIController) { if (targetTransform == null && detectsTarget) { detectsTarget = false; ai.SetRandomGoal(); } } }