void OnTriggerEnter2D(Collider2D other) { //check if we hit Player if (other.CompareTag("Player")) { //Find container controller ContainerController control = GameObject.FindGameObjectWithTag("Canvas").GetComponent <ContainerController>(); control.CandyHit(m_type); m_audio.PlayEatCandy(); } else { GameObject ps = Instantiate(m_explosion, transform.position + Vector3.up * 0.01f, Quaternion.identity); ////get particle system start color module //ParticleSystem.MainModule main = ps.GetComponent<ParticleSystem>().main; //ParticleSystem.MinMaxGradient grad = new ParticleSystem.MinMaxGradient(Color.blue, Color.red); //main.startColor.mode = m_audio.PlayGroundHit(); } //Debug.Log("Time to destroy"); //destroy candy when it hits Destroy(this.gameObject); }