I am making a racing game. The first scene is the main menu. The user chooses the track, their car, number of opponents and the number of laps, and then the track they would race on is loaded. I am saving that information attached to an empty game object that is set to DontDestroyOnLoad in my second scene, but it seems that the information is not being preserved, or I am not accessing it right.
This is the script attached to my terrain in the Second scene I am trying to load:
var AICar1 : GameObject;
var AICar2 : GameObject;
var AICar3 : GameObject;
var Car1 : GameObject;
var Car2 : GameObject;
var Car3 : GameObject;
var Info : GameObject;
var cam : GameObject;
var car : String;
var laps : int;
var enemies : int;
function pickCar()
{
if (car == "Dodge Charger")
{
cam.target = Car1;
Destroy(Car2);
Destroy(Car3);
}
else if (car == "EvoX")
{
cam.target = Car2;
Destroy(Car1);
Destroy(Car3);
}
else if (car == "Catamount")
{
cam.target = Car3;
Destroy(Car1);
Destroy(Car2);
}
}
function Start()
{
DontDestroyOnLoad(GameObject.Find("/RaceInfo"));
Info = GameObject.Find("/RaceInfo");
laps = Info.GetComponent("Menu").laps;
enemies = Info.GetComponent("Menu").enemies;
car = Info.GetComponent("car").ToString();
pickCar();
}
Am I doing something wrong here?