Exemple #1
0
 void Start()
 {
     SetPlayer();
     rigidbody.centerOfMass = new Vector3(0, -1f, 0);
     SetValues();
     kartStatus      = GetComponent <KartStatus>();
     GeomController  = GetComponent <KartWheelGeomController>();
     ItemsController = GetComponent <KartItemsController>();
 }
Exemple #2
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.name == "PlayerOneKart" || col.gameObject.name == "PlayerTwoKart")
        {
            KartItemsController kart    = col.gameObject.GetComponent <KartItemsController>();
            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.kartStatus.Hit();
                col.rigidbody.AddExplosionForce(500000.0f, contact.point, 10.0f, 10000.0f);
                col.rigidbody.AddTorque(Vector3.up * 10000000.0f);
            }
        }

        Destroy(gameObject);
    }