예제 #1
0
 void OnTriggerEnter(Collider other)
 {
     if (otherCar == null)
     {
         otherCar = other.transform.GetComponent <CarRaceController>();
     }
 }
예제 #2
0
 void OnTriggerExit(Collider other)
 {
     if (otherCar != null)
     {
         if (otherCar == other.transform.GetComponent <CarRaceController>())
         {
             otherCar = null;
         }
     }
 }
예제 #3
0
    void  OnTriggerEnter(Collider other)
    {
        CarRaceController car = other.GetComponent <CarRaceController>();

        if (car == null)
        {
            car = other.transform.parent.GetComponent <CarRaceController>();
        }
        if (car != null)
        {
            Debug.Log("It went through");
            gameManager.RespawnCar(car);
        }
    }
예제 #4
0
    void OnTriggerEnter(Collider other)
    {
        CarRaceController car = other.GetComponent <CarRaceController>();

        if (car == null)
        {
            car = other.transform.parent.GetComponent <CarRaceController>();
        }
        if (car != null && car.position == 1)
        {
            Debug.Log("FinishLine crossed");
            gameManager.FinishLineCrossed();

            gameObject.SetActive(false);
        }
    }
예제 #5
0
    public void RespawnCar(CarRaceController carToRespawn)
    {
        Debug.Log("Car is Respawning");
        carToRespawn.gameObject.transform.position = carRespawner.transform.position + carRespawner.transform.up * 2;

        if (carRespawner.reverse)
        {
            carToRespawn.gameObject.transform.rotation = carRespawner.transform.rotation * Quaternion.Euler(0, 180, 0);
        }
        else
        {
            carToRespawn.gameObject.transform.rotation       = carRespawner.transform.rotation;
            carToRespawn.GetComponent <Rigidbody>().velocity = Vector3.zero;
        }

        carToRespawn.transform.FindChild("NodeToFollow").GetComponent <FollowPathV2>().currentSpline = carRespawner.currentSpline;
        carToRespawn.transform.FindChild("NodeToFollow").GetComponent <FollowPathV2>().reverse       = carRespawner.reverse;
    }
예제 #6
0
    void OnTriggerEnter(Collider other)
    {
        CarRaceController car = other.GetComponent <CarRaceController>();

        if (car == null)
        {
            car = other.transform.parent.GetComponent <CarRaceController>();
        }
        if (car != null && car.position == 1 && other.gameObject.name != "NodeToFollow")
        {
            if (Vector3.Dot(transform.forward, other.transform.forward) < 0)
            {
                Debug.Log("It went through");
                gameManager.LapCounter();

                gameObject.SetActive(false);
            }
        }
    }