Hi again!
Right now I'm trying to make an endless tunnel. I have say about 5 prefabs stuck together to make a tunnel at the beginning of the level, for a start. When you get close to the end of this pre-done set of tunnels, I want it to create say 5 or 10 more after those. (They're on the Z axis)
I've been messing around with the various Instantiate functions, and I know that's what I need to do but it's just not working the way I want it to.
I was using the first Instantiate script from Unity's Instantiate scripting page and it's almost exactly what I want. It creates them and I can specify how many, and how spaced apart they are on what axis. Got all that working, set up a timer to make it only instantiate 10 every 10 seconds, but the problem is, it's creating the same 10 over each other every time. It doesn't know that I want them created further along the Z axis, from the last batch. Is there an easy way to do this? Still not a whiz at scripting so any help would be appreciated.
Thanks! :)
EDIT: My current script:
var prefab : Transform;
private var CreateTimer = 10.0;
private var NextCreate = 0.0;
function Update()
{
if(Time.time > CreateTimer + NextCreate)
{
NextCreate = Time.time;
for (var i : int = 0;i < 10; i++)
{
Instantiate (prefab, Vector3(0, 0, i * 47.87), Quaternion.identity);
}
}
}
↧