Hi! I have a problem since morning I want to delete collision.gameObject from my list but when I start a game the object turns from blue gameobject to gray and it isn’t respond maybe you have a idea how to do it. Here’s my Code:
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Item")) {
_name = collision.gameObject.name;
if (_itemList.GoldenChestItems.Contains(GameObject.Find(_name)))
{
_itemList.GoldenChestItems.Remove(GameObject.Find(_name));
}
if (_itemList.TreasureRoomItems.Contains(GameObject.Find(_name)))
{
_itemList.TreasureRoomItems.Remove(GameObject.Find(_name));
}
Destroy(collision.gameObject);
}
}