public void StartRace(int position) { StartCoroutine(CountDown()); GameObject gridSpot = GameObject.Find("Pos_" + position); localCar = null; localCar.gameObject.transform.position = gridSpot.transform.position; localCar.gameObject.transform.rotation = gridSpot.transform.rotation; localCar.gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero; localCar.GetComponentInChildren <CheckpointReader>().isLocal = true; localCar.PreRaceStart(); localUser = FindObjectOfType <DataController>().PlayerName; }
public IEnumerator EndRace() { gameplayUI.alpha = 0f; postRaceUI.alpha = 1f; i = PostRaceCountdownLength; while (i > 0) { //countdown down 30sec, after first placer crosses line. after that trigger post race countdownText.text = i.ToString(); i--; yield return(new WaitForSecondsRealtime(1)); } yield return(new WaitForSecondsRealtime(4)); //add trigger to camera script - quit following the car with a moderate damping effect, and move upwards //ill make a refrence or something of how it should go //add trigger to car brake, so when you cross finish line it would brake (carBehaviour.cs) // hey that i can do localCar.PreRaceStart(); //make the post-race UI and expose it on screen, //make the button to restart/exit //comes in english DataController dataController = FindObjectOfType <DataController>(); dataController.SetDirtiness(localCar.dirtiness); dataController.RaceResults = new RaceResults() { Laptimes = laptimes }; yield return(new WaitForSecondsRealtime(4)); SceneManager.LoadScene("post_race", LoadSceneMode.Single); }