
出入り口にコライダーを置いて、ドアの出入りを判定してみました。
このドアはX軸方向に通過するので、トリガーExitのときのプレイヤーとコライダーの位置のX軸の値を比べるだけです。


private void OnTriggerExit(Collider other)
{
if (other.name == "Door1")
{
//float distance = transform.position.x - other.bounds.center.x;
float distance = transform.position.x - other.transform.position.x;
if (distance >= 0) text.text = "入った";
else text.text = "出た";
}
}
これでドアの出入りを簡単に判定できました。