Answer the question
In order to leave comments, you need to log in
How to set different spawn coordinates for array objects?
Help, I created an array and put two objects in it that should spawn in different positions, but they do the opposite, how can I give them different coordinates?
Answer the question
In order to leave comments, you need to log in
Well, for starters, it's worth showing the code that does not work.
And then just specify where to spawn objects.
Here is a working code example:
public GameObject[] Prefabs; //тут говорим какие префабы спавнить
public void Start()
{
for (var index = 0; index < Prefabs.Length; index++)
{
Instantiate(Prefabs[index], Vector3.one * index, Quaternion.identity); //тут говорим: какой префаб спавнить, какие координаты и какой поворот
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question