I was wondering how to change the model in my game. What I am specifically trying to do is change the model of the car which is being used (its a racing game) depending on a variable. For example if my variable is 1 then a certain car (For example, an SUV) but if it is 2 then it is a sports car. I have searched online but have had great trouble changing the model via script.
Store all the models in an array and use the variable to get the model:
int modelNumber;
public GameObject [] modelArray;
GameObject currentModel;
void Start()
{
// modelNumber is given a value based on the player choice
// I leave that to you since I do not know how you do that
currentModel = modelArray[modelNumber];
}
void Update()
{
// Do stuff with your model
currentModel.transform.Translate(forward);
}
There could be other ways where the array is not kept all over the game since you only need to access the model in the Start but this one may be easier on you to understand right away.