So for class im making a project that uses one button only and not allowed the default rigidbody physics. I made all the movement and distance restrictions for the character my self but i need fish to spawn and cant seem to make it work. This is a script i found on the site and it just makes them all spawn everywhere, within the range limitation. How can i add a timer to this so they spawn periodically.
var thePrefab : GameObject;
var range: float = 12; // set the +/- range around the empty object
function Update () {
var pos = transform.position; // get this object’s position
pos.y += Random.Range(-range, range); // add a random x offset around it
var instance : GameObject = Instantiate(thePrefab, pos, transform.rotation);
}