예제 #1
0
    // Use this for initialization
    void Start()
    {
        audio = gameObject.GetComponent <AudioSource>();
        GameObject thecar = transform.root.gameObject;

        carscript = transform.root.GetComponent <NewCaz>();
    }
예제 #2
0
    /*
     * Creates a water "explosion" when the car hits a water surface.
     *
     *
     * */

    IEnumerator OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")
        {
            //Create Explosion at point of impact (instantiates explosion particle and then destroys it after it plays).
            Vector3 crashPos = col.transform.position;
            explosionAudio = GameObject.Find("WaterSound").GetComponent <AudioSource>();
            explosionAudio.Play();
            Object splush = Instantiate(GameObject.Find("Splash"), crashPos, Quaternion.identity);
            Destroy(splush, 0.8f);



            //Make car the collider of the object hitting the trigger.
            car = GameObject.FindGameObjectWithTag("Player");


            //Make car the parent object.
            car = car.transform.gameObject;

            //Change the Destroyed Variable of the car
            carscript = car.GetComponent <NewCaz>();
            carscript.carDestroyed = true;
            carscript.dead_timer   = 3f;


            //Reset the car speed to 0. And wait 5 seconds until it respawns somewhere.
            car.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
            yield return(new WaitForSeconds(3.0f));

            car.transform.position = carscript.respawnPointArray[carscript.currentCheckpoint].position;
            car.transform.rotation = carscript.respawnPointArray[carscript.currentCheckpoint].rotation;
        }
    }
    //Fill the array with the caamera positions for the race preview
    void Start()
    {
        //Get the scripts corresponding to this car
        mainCarScript = transform.root.GetComponent <NewCaz>();
        camChange     = transform.root.GetComponent <cam_change>();
        //Fill the array (indexes 0 and 1 will be useless)
        cameraPos = transform.parent.GetComponentsInChildren <Transform>();
        //Set first camera at position 2
        transform.position = cameraPos[2].position;
        transform.rotation = cameraPos[2].rotation;


        preview = RunPreviewCamera();
        StartCoroutine(preview);

        //Set the racing state to false in the maincarscript
        mainCarScript.racing = false;

        //Get Fanari GUIs
        fanaria = GameObject.Find("Fanari").GetComponentsInChildren <Image>();

        for (int i = 0; i <= 3; i++)
        {
            fanaria[i].enabled = false;
        }

        //Set Previewing to true so the user can't change cameras with enter on cam_change script
        camChange.previewing = true;
    }
예제 #4
0
    void Start()
    {
        carscript = transform.root.GetComponent <NewCaz>();

        maxSpeed = Quaternion.Euler(0, 0, rotationAngle);
        minSpeed = Quaternion.Euler(0, 0, -rotationAngle);

        startRotation = transform.localRotation;
        endRotation   = transform.localRotation * minSpeed;
    }
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Player")
     {
         /*
          * Debug.Log(col.gameObject);
          * Debug.Log(CheckPointZoneNumber);
          */
         script = col.gameObject.GetComponent <NewCaz>();
         script.currentCheckpoint = CheckPointZoneNumber;
         //Set true the array index of the car checkpoints to true
         script.fairRace[CheckPointZoneNumber] = true;
     }
 }
예제 #6
0
 //private bool tyre_grounded;
 // Use this for initialization
 void Start()
 {
     newCazScript = transform.root.GetComponent <NewCaz>();
 }
예제 #7
0
    // Update is called once per frame


    void Start()
    {
        thecar = GameObject.Find("Car 1");  //<-------------NEEDS FIX NOT TO GET IT LIKE THIS BUT BY THE ONE IT COLLIDES WITH
        script = thecar.GetComponent <NewCaz>();
    }