Hi I have a box as the child of my player and with this code it spawns enemy units every 3 seconds. What I need is for the units to spawn in a range of random y positions in side the box (the box is very tall to accommodate a wide range of positions). If not this then I can make the box smaller or switch it for an empty gameobject and have it move around in the y axis to spawn the units from there. I’ve read up on random.range but I am unsure on how to utilize it here. This script is attached to the spawn box. I also need advice as to what I can use to make my flying monsters fly to my players current position at the moment the spawn, but not in a homing missile type of way(dont need this scripted for me I would just appreciate some advice o what function I could use). Thank you in advance for any response.
var hero : GameObject;
var flying : GameObject;
var spawner : Transform;
InvokeRepeating("Spawn", 2, 3);
function Update ()
{
var positiony = transform.position.y;
positiony = hero.transform.position.y;
}
function Spawn()
{
Instantiate(flying,spawner.position, spawner.rotation);// its instattiating at 0,0,0 i need to follow this up with corrdinates
}