private void Start() { Debug.Assert(endGo != null); Debug.Assert(momGo != null); Debug.Assert(kidGo != null); endGo.SetActive(false); instance = this; }
/// <summary> /// Instantiates the correct kart every level. /// </summary> public void InitLevel(string sceneName) { //print("InitLevel"); GameObject trackManagerGO = GameObject.Find("TrackManager"); GameObject displayGO = GameObject.Find("TimeDisplayCanvas"); GameObject kartGO = null; Vector3 kartPos = Vector3.zero; if (sceneName == "Level1") { kartPos = sceneData.level1KartPos; } else if (sceneName == "Level2") { kartPos = sceneData.level2KartPos; } if (isVR) { kartGO = Instantiate(VRKart, kartPos, Quaternion.identity); } else { GameObject kartParent = Instantiate(mobileKart, Vector3.zero, Quaternion.identity); // Get the kart gameobject kartGO = kartParent.transform.GetChild(1).gameObject; kartGO.transform.position = kartPos; } // Add kart references to classes that require it KartMovement movement = kartGO.GetComponent <KartMovement>(); Racer racer = kartGO.GetComponent <Racer>(); KartRepositionTrigger kartRepoTrig = trackManagerGO.GetComponent <KartRepositionTrigger>(); TimeDisplay display = displayGO.GetComponent <TimeDisplay>(); AudioSource audio = GameObject.Find("BackgroundMusic").GetComponent <AudioSource>(); audio.enabled = true; audio.Play(); kartRepoTrig.SetMovable(movement); display.SetRacer(racer); display.enabled = true; kartRepoTrig.enabled = true; trackManagerGO.GetComponent <TrackManager>().StartTrackManager(); display.StartDisplay(); // Set the Racer for EndController endController = GameObject.Find("EndGameController").GetComponent <EndController>(); endController.playerRacer = racer; }