P
P
Poly Mamylop2021-09-12 15:17:35
C++ / C#
Poly Mamylop, 2021-09-12 15:17:35

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

1 answer(s)
A
Andrey Boronnikov, 2021-09-16
@red-cat-fat

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 question

Ask a Question

731 491 924 answers to any question