How can I set an instantiated gameobject's model in code?

Hi everyone, in my code I have a function which creates a gameobject for each object in a list. They each appear in the hierarchy, but now I would like to give each of them a different model depending on their place in the loop.

For simplicity’s sake, here is an example of the code without the loop.

fieldCharacter = new GameObject();
fieldCharacter.name = "Doug";
fieldCharacter.tag = "Character";

Is there a way to do this?

1 Answer

1

Did you checked the Instantiate method? With it, you can instantiate your prefabs.

is it possible to change the model of the prefab once it's been created?

Check [this][1]. [1]: http://answers.unity3d.com/questions/299425/how-do-you-change-a-players-3d-model-via-a-script.html