void OnCollisionEnter(Collision other) //碰撞一次 { if (other.collider.CompareTag("Wall")) //碰到墙 { if (wall != other.transform) //且不是上次的墙 { wall = other.transform; //获取该墙 dm.GetWall(other.transform); } } gameObject.SetActive(false); }