# How to instantiate multiple objects at the same time but at different Vector3 positions?

Hello Community,

I would like to instantiate multiple objects at the same time in a vertical arrangement. Currently my code looks like this:

``````        GameObject hazard = hazards [Random.Range (0, hazards.Length)];
Vector3 spawnPosition1 = new Vector3 (20, 5, 0);
Vector3 spawnPosition2 = new Vector3 (20, 3, 0);
Vector3 spawnPosition3 = new Vector3 (20, 1, 0);
Vector3 spawnPosition4 = new Vector3 (20, -1, 0);
Vector3 spawnPosition5 = new Vector3 (20, -3, 0);
Vector3 spawnPosition6 = new Vector3 (20, -5, 0);
Quaternion spawnRotation = Quaternion.identity;
Instantiate (hazard, spawnPosition1, spawnRotation);
Instantiate (hazard, spawnPosition2, spawnRotation);
Instantiate (hazard, spawnPosition3, spawnRotation);
Instantiate (hazard, spawnPosition4, spawnRotation);
Instantiate (hazard, spawnPosition6, spawnRotation);
``````

Is there a way to instantiate all my hazards at their respective positions in a single line of ‘Instantiate’-code, instead of having to repeatedly instantiate each individual object at each individual position?

Thank you!!

Loops and arrays are your friends.

``````public GameObject[] hazards;

void Start()
{
GameObject hazard = hazards[Random.Range(0, hazards.Length)];
Vector3[] spawnPositions = new[] { new Vector3(20, 5, 0), new Vector3(20, 3, 0), new Vector3(20, 1, 0), new Vector3(20, -1, 0), new Vector3(20, -3, 0), new Vector3(20, -5, 0) };
Quaternion spawnRotation = Quaternion.identity;
for(int i = 1; i < 6; i++)
{
Instantiate(hazard, spawnPositions*, spawnRotation);*
``````

}
}