Question by
sid4 · Nov 27, 2016 at 01:45 PM ·
instantiate
instantiate 1 only each time not clone all of whats on screen continuoslly
this script does instantiate but when it gets to lets say 8 clones it will then instantiate the exact amount so this is way to many
for example at start it instantiates 1 copy since theres only 1 there but then after it will continue to clone with whatever is there so for example when its has 10 clones it will next start cloning 10 then 20 then 40 then 80 etc I only want it to start at 1 then 1 more then 1 more then 1 more etc
this is to much I ONLY WANT 1 EACH INSTANTIATION please help ive spent days trying to search and figure this out
I do have a few spawn points
2d game
#pragma strict
public var spawnFrequency: float = 3f; // 3 seconds
public var prefab: GameObject;
var Spawns : Transform[];
function Start () {
if (prefab != null)
{
InvokeRepeating("SpawnItem", 3.0f, 6.0f );
}
}
function SpawnItem () {
if (prefab != null)
{
if (Spawns.Length >= 2)
{
Instantiate( prefab, Spawns[Random.Range( 2, Spawns.Length)].position, Spawns[0].rotation);
}
else
{
Instantiate( prefab );
}
}
}
Comment