how to instantiate a certain gameobject from an array

I want to instantiate a certain gameobject from an array. For example if I have a dog round I don’t want zombies to spawn on the round/wave.

So have two different arrays. One with dogs, one with zombies. During dog round, spawn from DogList, etc.

No they are in the same array.

So how do you intend to identify which index is what you want?

That’s what i’m trying to figure out if there is way to do that.

Use different arrays.

Im trying to do it with one array.

Then you have to loop over the array and check each item for some sort of identifier that says whether it is a Dog or Zombie.

This is a bad way to do it, considering the alternatives.

I’m guessing you have an array of prefabs?

You could try having it both ways by having an array of prefabs, then on startup, walk through the list of prefabs and build a Dictionary<Type, List> based on what you’re looking for, to better organize the prefabs.

Of course, this is assuming you have a Dog component that you can use GetComponent with.

It doesn’t even need to be a Dog component, it could be some Entity component with an enum value to identify it as Dog.

I personally prefer this over using tags.

oh ok

ok