I'm making a script to generate power-ups. So far this is what I have:
var prefab : Transform;
var timer = 10.0;
var countdown = 1.0;
var xpos = 0;
var ypos = 0;
var zpos = 0;
function Update ()
{
if (timer > 0)
{
timer -= countdown * Time.deltaTime;
}
if (timer < 0)
{
timer = 0;
}
if (timer == 0)
{
Instantiate (prefab, Vector3(xpos, ypos, zpos), Quaternion.identity);
timer = 10.0;
}
}
How can I impliment a function that will cause the position of the objects spawn to change each time? I need to be able to change the variables xpos and zpos (x and z posisions) to anywhere from 0 to 25. I know the Range function will do this, but I don't know how to correctly type the script. Can someone show me a simple script to generate a random number from 0 to 25?