using UnityEngine;
using System.Collections;
public class SpawnScript : MonoBehaviour {
public GameObject meteor;
float spawnThreshold = 100;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Random.Range (0, spawnThreshold)<=1){
Instantiate(meteor, new Vector3(11, Random.Range(-3, 6.5), 0));
}
}
}
This is the code i’ve been using to instantiate a meteor prefab. However, when I try to run it Unity complains with the error “UnityEngine.Random.Range(float, float) has some invalid arguments”. I’m not sure whats wrong with it, as I’m quite new to this. Also, if there is a way to spawn a meteor every second or frequently, then please do say:). Any help would be very much appreciated.