유니티 기초

포탈 한번만 나오기 수정 & 아이템먹기

노재두내 2023. 8. 10. 18:05
private bool isExisted = true;
Debug.LogFormat("this.monsterList.Count: {0}", this.monsterList.Count);
                    if (this.monsterList.Count <= 0&&this.isExisted==true)
                    {
                         this.CreatePortal();
                         isExisted = false;
                    }

--> 포탈 한번만 나오기 수정완료

 

private void OnTriggerEnter(Collider other)
        {
            var item = other.gameObject.GetComponent<ItemController>();
            
            if (item != null)
            {
                Debug.LogFormat("<color=red>{0}아이템 지나침</color>",item.ItemType);
                other.gameObject.SetActive(false);
            }
        }

gameobject 아이템을 어떻게 불러오나 생각했는데 생각해보니 other이 만나는 gameobject 즉 item object였다.