예제 #1
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.name == "PlayerOneKart" || col.gameObject.name == "PlayerTwoKart")
     {
         KartController kart    = col.gameObject.GetComponent <KartController>();
         ContactPoint   contact = col.contacts[0];
         Quaternion     rot     = Quaternion.FromToRotation(Vector3.up, contact.normal);
         Vector3        pos     = contact.point;
         Instantiate(Explosion, pos, rot);
         if (!kart.shieldEnabled)
         {
             kart.SubtractLife();
             col.rigidbody.AddExplosionForce(500000.0f, contact.point, 10.0f, 10000.0f);
             col.rigidbody.AddTorque(Vector3.up * 10000000.0f);
         }
         Destroy(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }