Why does the following code not work?
I want to instantiate prefabs in a list and then use it as a GameObject like that :
public GameObject prefab;
void Start()
{
ArrayList players = new ArrayList();
for(int i=0; i<5; i++)
{
players.Add( (GameObject)Instantiate(prefab));
}
players[2].transform.position = new Vector3(1, 1, 1);
}
there is an error message
No comments:
Post a Comment