void OnTriggerEnter2D(Collider2D collision) { // Deletes bunnies if they touch the box if (collision.gameObject.tag == "Bunny") { int value = gameObject.GetComponent <TruckAlgo>().removeBunny(collision.gameObject.GetComponent <BunnyAI>().breed); //collision.gameObject.GetComponent<BunnyAI>().value BunnyStats.setGold(BunnyStats.getGold() + value); Destroy(collision.gameObject); BunnyStats.removeBunny(collision.gameObject.GetComponent <BunnyAI>().breed); } }