If an enemy is nearby, the door will automatically close.
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { Debug.Log("EnemyIn"); doorClose = true; } } private void OnTriggerExit(Collider other) { if (other.CompareTag("Enemy")) { Debug.Log("EnemyOut"); doorClose = false; } }