Example #1
0
 void OnCollisionEnter(Collision col)
 {
     if (!hitOnce && col.gameObject.GetComponent <BallChainMovement>() != null)
     {
         hitOnce = true;
         villain.spawnCount++;
         foreach (GameObject b in bc)
         {
             ind++;
             if (col.gameObject.name == b.gameObject.name)
             {
                 collision_index = ind;
                 collided_GO     = b.gameObject;
             }
         }
         if (collision_index < bc.Count - 1)
         {
             CheckNeighbourColors(collision_index, collided_GO);
         }
         //GetComponent<MeshRenderer>().enabled = false;
         GetComponent <SphereCollider>().enabled = false;
         transform.GetChild(0).gameObject.SetActive(false);
         explosion.CreateExplosion(transform.position);
         Destroy(gameObject, 0.5f);
         soundManager.PlayChangeColorAudio();
     }
     else
     {
         hitCount++;
     }
 }