Only 2 out of 4 Objects ever spawn... Why ?(Closed)

I’m using the following script to spawn my weapons in game. I have 4 weapons and 4 spawn locations. A weapon will always spawn in all 4 locations BUT its only ever ‘wep03’ or ‘wep04’ never ‘wep01’ or ‘wep02’
I must have ran it 60-70 times (no exaggeration) and never had anything but the same 2 weapons.

//Weapon prefabs to spawn
var wep01 : GameObject;
var wep02 : GameObject;
var wep03 : GameObject;
var wep04 : GameObject;

//Spawn points
var spawnPoint1 : Transform;
var spawnPoint2 : Transform;
var spawnPoint3 : Transform;
var spawnPoint4 : Transform;

function Start()
{
	SpawnWeapons(); // Run SpawnWeapons coroutine
}

function SpawnWeapons()
{
	for(var i=0;i<4;i++) // Run loop 4 times
	{
		var random1 : int = Random.Range(0,4);

		switch (random1)
		{
			case (0):
			var spawnWep1 = Instantiate(wep01);
			switch (i)
		{
			case (0):
			spawnWep1.transform.position = new Vector3(spawnPoint1.transform.position.x, spawnPoint1.transform.position.y, spawnPoint1.transform.position.z);
			spawnWep1.transform.tag = "Weapon01";  
			break;
			case (1):
			spawnWep1.transform.position = new Vector3(spawnPoint2.transform.position.x, spawnPoint2.transform.position.y, spawnPoint2.transform.position.z);
			spawnWep1.transform.tag = "Weapon02";  
			break;
			case (2):
			spawnWep1.transform.position = new Vector3(spawnPoint3.transform.position.x, spawnPoint3.transform.position.y, spawnPoint3.transform.position.z);
			spawnWep1.transform.tag = "Weapon03";  
			break;
			case (3):
			spawnWep1.transform.position = new Vector3(spawnPoint4.transform.position.x, spawnPoint4.transform.position.y, spawnPoint4.transform.position.z);
			spawnWep1.transform.tag = "Weapon04";  
			break;	
		}
			case (1):
			var spawnWep2 = Instantiate(wep02);
			switch (i)
		{			
			case (0):
			spawnWep2.transform.position = new Vector3(spawnPoint1.transform.position.x, spawnPoint1.transform.position.y, spawnPoint1.transform.position.z);
			spawnWep2.transform.tag = "Weapon01";  
			break;
			case (1):
			spawnWep2.transform.position = new Vector3(spawnPoint2.transform.position.x, spawnPoint2.transform.position.y, spawnPoint2.transform.position.z);
			spawnWep2.transform.tag = "Weapon02";  
			break;
			case (2):
			spawnWep2.transform.position = new Vector3(spawnPoint3.transform.position.x, spawnPoint3.transform.position.y, spawnPoint3.transform.position.z);
			spawnWep2.transform.tag = "Weapon03";  
			break;
			case (3):
			spawnWep2.transform.position = new Vector3(spawnPoint4.transform.position.x, spawnPoint4.transform.position.y, spawnPoint4.transform.position.z);
			spawnWep2.transform.tag = "Weapon04";  
			break;
		}
			case (2):
			var spawnWep3 = Instantiate(wep03);
			switch (i)
		{			
			case (0):
			spawnWep3.transform.position = new Vector3(spawnPoint1.transform.position.x, spawnPoint1.transform.position.y, spawnPoint1.transform.position.z);
			spawnWep3.transform.tag = "Weapon01";  
			break;
			case (1):
			spawnWep3.transform.position = new Vector3(spawnPoint2.transform.position.x, spawnPoint2.transform.position.y, spawnPoint2.transform.position.z);
			spawnWep3.transform.tag = "Weapon02";  
			break;
			case (2):
			spawnWep3.transform.position = new Vector3(spawnPoint3.transform.position.x, spawnPoint3.transform.position.y, spawnPoint3.transform.position.z);
			spawnWep3.transform.tag = "Weapon03";  
			break;
			case (3):
			spawnWep3.transform.position = new Vector3(spawnPoint4.transform.position.x, spawnPoint4.transform.position.y, spawnPoint4.transform.position.z);
			spawnWep3.transform.tag = "Weapon04";  
			break;
		}
			case (3):
			var spawnWep4 = Instantiate(wep04);
			switch (i)
		{			
			case (0):
			spawnWep4.transform.position = new Vector3(spawnPoint1.transform.position.x, spawnPoint1.transform.position.y, spawnPoint1.transform.position.z);
			spawnWep4.transform.tag = "Weapon01";  
			break;
			case (1):
			spawnWep4.transform.position = new Vector3(spawnPoint2.transform.position.x, spawnPoint2.transform.position.y, spawnPoint2.transform.position.z);
			spawnWep4.transform.tag = "Weapon02";  
			break;
			case (2):
			spawnWep4.transform.position = new Vector3(spawnPoint3.transform.position.x, spawnPoint3.transform.position.y, spawnPoint3.transform.position.z);
			spawnWep4.transform.tag = "Weapon03";  
			break;
			case (3):
			spawnWep4.transform.position = new Vector3(spawnPoint4.transform.position.x, spawnPoint4.transform.position.y, spawnPoint4.transform.position.z);
			spawnWep4.transform.tag = "Weapon04";  
			break;
		}
			break;
		}

	}

}

What the hell am I doing wrong?

(The script is in JavaScript and please reply as though your explaining it to a 5 year old…lol)

Any help is much appreciated !

You should put Debug.Log(“creating weapon 1”); etc in your code, to see exactly where the code is/isn’t running.

Also your “switch(random1)” is missing breaks after each case. So if it was 0, it would then fall down to case 1 and get replaced, etc.

Try fixing that and putting in a lot of Debug.Log’s to see exactly how your code is behaving. :slight_smile:

Thanks for the help guys but I think I’m trying to run before I can walk. I’m going to go back to an older (but simpler) script I was using. Although very basic I wrote it myself and can at least follow it and can expand it and learn at the same time.
May come back to this script at a later date when I’m a little (or a lot) more competent…lol
Again… many thanks for the help !