So I am trying to make my enemys spawn in completly random parts along the x value. So I want them to always spawn at the same z and same y values, but a random x. How would I go about doing this. Also if you could incorporate how I would make the enemys that spawn also be random out of a 1,2,and 3 instance that would be great!
PS. I am using JS
You should try to use the Random class for that.
For example, if you want to instantiate a prefab randomly along the x-axis, you could go like that (sorry it’s in C# but it must be pretty close in JS) :
float randomXValue = Random.Range(minimalRandomValue,maximalRandomValue);
GameObject.Instantiate(myPrefab,new Vector3(randomXValue,constantY,constantZ),Quaternion.identity);
For choosing among three instance, you could store those 3 instances in an array and do that :
int instanceChoice = (int)(Random.Range(0,myInstanceArray.Length-0.1f));
float randomXValue = Random.Range(minimalRandomValue,maximalRandomValue);
GameObject.Instantiate(myInstanceArray[instanceChoice],new Vector3(randomXValue,constantY,constantZ),Quaternion.identity);