private void bigFood(string tag) { foodList = GameObject.FindGameObjectsWithTag(tag); for (int i = 0; i < foodList.Length; i++) { foodClone = (food)foodList[i].gameObject.GetComponent(typeof(food)); if (foodClone.getType() == 1) { foodClone.transform.localScale = new Vector3(.60f, .60f, 0); CapsuleCollider myCollider = foodClone.transform.GetComponent <CapsuleCollider>(); myCollider.radius = 4f; } } }
void OnTriggerEnter(Collider other) { if (other.gameObject.name == "food(Clone)") { food eat = (food)other.gameObject.GetComponent(typeof(food)); if (0 == eat.getType()) { game.updateScore(eat.getWeight()); audio.PlayOneShot(fart); } else { game.ateHealthy(); audio.PlayOneShot(ralph); } Destroy(other.gameObject); Instantiate(crumbsplosion, transform.position, Quaternion.identity); } }