- Home /
Question by
TheLordDesigns · Apr 20, 2016 at 01:37 PM ·
xcode 5
Random spawning
Hello im trying to make my enemy spawn at one of three locations randomly and i made a script but after some time it start to spawn at all three locations at once :P . if (vreme < 0) { vreme = 10; Debug.Log (broj); broj = Random.Range (1, 4);
if (broj < 2 && broj > 0) {
Instantiate (EK, SPoint1, Quaternion.identity);
broj = 0;
}
if (broj < 3 && broj > 1) {
broj = 0;
Instantiate (EK, SPoint2, Quaternion.identity);
}
if (broj > 2) {
Instantiate (EK, SPoint3, Quaternion.identity);
broj = 0;
}
}
Comment
Best Answer
Answer by Ali-hatem · Apr 20, 2016 at 02:19 PM
public Vector3 [] SPoint;
if(time to spawn){
Instantiate (EK, SPoint[Random.Range(0,SPoint.Length)], Quaternion.identity);
}
Your answer
Follow this Question
Related Questions
Xcode 5.1 - Numerous compile errors 0 Answers
UI object not fitting with the device in simulator 2 Answers
unwanted cubemap 0 Answers
Xcode gives directorynotempty error with UnityAds.bundle 0 Answers