Пример #1
0
    private void OnTriggerEnter(Collider collider)
    {
        CarModel otherCar = collider.GetComponent <CarModel>() as CarModel;

        if (otherCar != null)
        {
            //  Destroy(otherCar.gameObject);
            Vector3 vecToOtherCar = otherCar.transform.position - this.transform.position;
            vecToOtherCar.Normalize();


            carModel.PushCar(-carModel.transform.up, reboundSpeed);
            float carspeed    = carModel.GetCarVelocity().magnitude;
            float bounceSpeed = carspeed * collisionPower;
            if (bounceSpeed < minimumCollisionSpeed)
            {
                bounceSpeed = minimumCollisionSpeed;
            }

            otherCar.PushCar(vecToOtherCar, bounceSpeed);
            otherCar.RegisterHitByPlayer(playerNumber);

            collisionSound.Play();
        }
    }