Hi,
I’ve been checking out the car tutorial that comes with unity and I’ve tweaked it to my liking so I can use it in future games but I’d like to be able to change the body model of it with a keypress, eg. press p for porsche and so on. I’ve looked through the forums and there was a similar topic that I made this script from and attached it to the car gameobject of which the Body (original model) and the porsche model are children.
var modelOne = GameObject.Find("Catamount");
var modelPorsche = GameObject.Find("Porsche");
function Update(){
if Input.GetButtonUp("c")){
modelOne.SetActiveRecursively(true);
modelPorsche.SetActiveRecursively(false);
}
if Input.GetButtonUp("p")){
modelOne.SetActiveRecursively(false);
modelPorsche.SetActiveRecursively(true);
}
}
Now Unity is telling me that you are not allowed to call this function when declaring a variable and since the Porsche model is a child of the car class, it displays both models at the same time. Has anybody done anything like this? Any help would be appreciated. Thank-you,
Anna