Unity3D - Create Many Objects

preview_player
Показать описание
Make 100 objects when the game starts with a "for loop" and instantiate. In this case, our object has the "rigidbody" component attached, so it falls and hits things.

This introductory video assumes you know very little about computer programming and Unity3D. Made with Unity 4.3.

Рекомендации по теме
Комментарии
Автор

I am doing this in a 2d project and it comes up with "The Object You Want To Instantiate is null". I've checked it all and it should work although it is not. This is my code :
GameObject grass = Resources.Load("Grass") as GameObject; ;

for (int x = -10; x < 10; x++)
{
map[x + 10] = Instantiate(grass);
map[x + 10].transform.position = new Vector3((float)x * scale, 0f);
}

james.
welcome to shbcf.ru