Hey guys. I have a problem with my code. I want to make an enemy that it can show up everywhere and when I click that I get a poin, and the problem is when I run it the enemy doesn’t show up. I thing there is a problem with this RandomScript. Can you help me guys?
Here’s the script…
public class RandomScript : MonoBehaviour {
public GameObject[] bocor;
public GameObject[] bocorSedang;
public GameObject[] bocorBesar;
public Transform bocorK;
public Transform bocorS;
public Transform bocorB;
Transform bolong;
void SpawnBocor(){
float x = Random.Range (5, 5);
float y = Random.Range (5, 5);
int R = Random.Range (-100, 100);
switch (R) {
case 0: bolong = Instantiate(bocorK) as Transform;
break;
case 1: bolong = Instantiate(bocorS) as Transform;
break;
case 2: bolong = Instantiate(bocorB) as Transform;
break;
}
bolong.position = new Vector3 (x, y, 5);
}
void Start(){
InvokeRepeating ("SpawnBocor", 1f, 4f);
}
}