private void OnCollisionEnter(Collision collision) { GameObject collidedObject = collision.gameObject; Branch branch = collidedObject.GetComponent <Branch>(); if (branch != null) { shader.animate = true; // tell the house manager how much to decrement branchCount by houseManager.DestroyHouse(branch.antiValue); // remove the branch prefab Destroy(collidedObject); // play trash can sound audioSource.PlayOneShot(trashcanSound, 10f); } if (collidedObject.GetComponent <PlayerController>()) { collidingObjects.Add(collidedObject); } }
public void DestroyHouse(int numToDecrBy) { houseManager.DestroyHouse(numToDecrBy); }