- Home /
Question by
MetalLord · Sep 25, 2012 at 04:52 PM ·
prefabrandomrandom.range
Random.Range not working.
So,i'm trying to make a enemy drop a random prefab when he is killed with a 1/5 chance,but the enemies drop the prefabs every time,the prefab itself is random each time,but their drop every time and not only with a small change.
public GameObject [] array;
private int seed;
public float life;
void Start()
{
seed = (Random.Range(0,6));
}
void OnTriggerEnter (Collider COL) {
if(COL.tag ==("weapon")){
life -=1;
Destroy(COL.gameObject);
}
}
// Update is called once per frame
void Update () {
if (life <= 0){
if(seed == 2);
{
Instantiate ((array[Random.Range(0, array.Length)]),this.transform.position,this.transform.rotation);
}
Destroy(this.gameObject);
}
}
}
Comment
Best Answer
Answer by DaveA · Sep 25, 2012 at 05:23 PM
You have an extra ; at the end of that if (seed == 2); Remove that ;