private void OnTriggerEnter(Collider other)
    {
        CarBehavior car         = other.gameObject.GetComponent <CarBehavior>();
        float       carRotation = other.gameObject.transform.rotation.eulerAngles.y;

        if (carRotation != goalRotation)
        {
            float rotationDifference = goalRotation - carRotation;
            car.SetNewRotation(rotationDifference, rotationSpeed);
        }
    }
Beispiel #2
0
    private void OnTriggerEnter(Collider other)
    {
        CarBehavior car = other.gameObject.GetComponent <CarBehavior>();

        if (car.road == road)
        {
            if (alternateRoad)
            {
                if (Random.Range(0, 2) == 1)
                {
                    car.SetNewRotation(alternateAngle, alternateSpeed);
                }
                else
                {
                    car.SetNewRotation(rotationAngle, rotationSpeed);
                }
            }
            else
            {
                car.SetNewRotation(rotationAngle, rotationSpeed);
            }
        }
    }