private void OnCollisionEnter(Collision collision) { // When ball trigger the trap, resize it. if (collision.gameObject.CompareTag("Trap")) { Traps trap = collision.gameObject.GetComponent <Traps>(); bool randomTrap = Random.Range(0, 10) < 5; if (randomTrap) { StartCoroutine(trap.ScaleUp(gameObject)); } else { StartCoroutine(trap.Shrinking(gameObject)); } } }