private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.name.StartsWith("Block")) { var item = collision.GetComponent <Collectible>(); if (item && item.id != "") { inventory.Add(item.id); SendUpdateInventory(); Destroy(collision.gameObject); } } if (collision.gameObject.name.StartsWith("Potion")) { var potion = collision.GetComponent <Potion>(); if (potion) { stats.AddMana(potion.amount); Destroy(collision.gameObject); } } }