How to Instantiate a single object after regular intevals ?

I am working on a temple run style game.How do i instantiate an object after some time ?
I have made a function and used yield…and no success :frowning: .
And what I get is many unlimited number of objects get instantiated.
Please Help I am new to Unity.

One easy way is [InvokeRepeating()][1]. [1]: http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=invokerepeating

Paste your coroutine/yield code.

1 Answer

1

Hey this should help you: I hope this is the effect you were trying to get

// The object to be Instantiated 
public var object : GameObject;

// Time before first Instantiate
public var firstInstantiate : float = 2;

//Set repeatRate to 0 if you only want to create 1 object
public var repeatRate : float = 2;

function Start () {

	InvokeRepeating("Instantiate", firstInstantiate , repeatRate);
}

function Instantiate () {

	Instantiate (object, Vector3(0, 0, 0), Quaternion.identity);
}

Works Like a Charm !!! ThankYou Really !