private void OnTriggerExit(Collider other) { if (other.tag == "Player") { if (woodenDoorStates == WoodenDoorStates.OpenFront || woodenDoorStates == WoodenDoorStates.OpenBack) { woodenDoorStates = WoodenDoorStates.Closed; } } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { Vector3 targetDirection = playerTransform.position - doorTransform.position; if (woodenDoorStates == WoodenDoorStates.Closed) { woodenDoorStates = (Vector3.Dot(doorTransform.forward, targetDirection) > 0) ? WoodenDoorStates.OpenBack : WoodenDoorStates.OpenFront; } } }