- Home /
Question by
usamagk · Mar 25, 2013 at 05:10 PM ·
instantiateobject
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 :( . And what I get is many unlimited number of objects get instantiated. Please Help I am new to Unity.
Comment
Best Answer
Answer by SP0KK0 · Mar 25, 2013 at 06:50 PM
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);
}
Your answer
Follow this Question
Related Questions
What should I change in this instantiating a GameObject in a script using Unity? 1 Answer
A node in a childnode? 1 Answer
Instantiate in Editor 1 Answer
How can i randomly create an array of objects without colliding one another? 1 Answer
Instantiating droppable items on destroy game object 1 Answer