Instantiate Object at the Position of an Object from a List

Please use code tags .

Basically, you want to change this line:

GameObject object = Instantiate(objects[randomObjects], transform.position, transform.rotation);

to something like this:

GameObject object = Instantiate(objects[randomObjects], Spawners[randomSpawn].position, Spawners[randomSpawn].rotation);

For simplicity, I assumed that Spawners is a collection of Transforms. If it’s actually GameObjects or MonoBehaviours or something, you’ll need to add an extra “.transform” between it and “.position” or “.rotation”.

“If that position already has an object spawned at it” could be interpreted in a few different ways, which would require different implementations of varying difficulty. The easiest interpretation is to say that each spawn point should only be used once, ever. To do that, you can just remove the spawn point from the list after you use it, so that next time you are selecting from a smaller list that doesn’t include the points you already used.

But although you said that “Objects” and “Spawners” were “lists”, from the way you are using them, I would guess they are actually arrays (for Lists, you would be using .Count instead of .Length). That makes it hard to remove a single item. So you probably want to switch to using actual Lists, and then you can remove the spawner you used by saying

Spawners.RemoveAt(randomSpawn);

(The main difference between arrays and lists is that lists can change in size, so you can add or remove elements, but arrays have a fixed size, so you can replace elements but can’t expand or contract the collection as a whole.)