J
J
JamCake2020-05-01 14:37:19
C++ / C#
JamCake, 2020-05-01 14:37:19

How to access all elements of an array?

5eac095f5301c589183202.png
When the player touches the collider, all objects should appear from the array, how to do this ? But at the same time, there is an indefinite number of objects in the array

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Dyupachev, 2020-05-01
@JamCake

You need to loop through all the objects in the array and call the SetActive method on each of them.

2
2CHEVSKII, 2020-05-01
@2chevskii

Do you know what cycles are?

C
Collin, 2020-05-02
@Collin

for (int i = 0; i < Enemy.Lenght; i++)
{
Enemy[i].SetActive(true);
}

or using foreach.
foreach(GameObject gObj in Enemy)
{
gObj.SetActive(true);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question