void OnTriggerStay2D(Collider2D other) { if (other != null) { Cow t = other.gameObject.GetComponent <Cow> (); if (t.CompareTag("PickUp") && cowCount == t.cowCount && Input.GetMouseButtonUp(0)) { Destroy(other.gameObject); var newCow = Instantiate(nextCow, transform.position, transform.rotation); newCow.transform.parent = GameObject.Find("Cows").transform; Destroy(gameObject); cowCount *= 2; } } }