How can i instantiate a gameobject 3 seconds after one of the objects is destroyed???
Invoke will call a function after waiting for some time.
void Start()
{
Invoke("CreateMyInstance", 3.0f);
}
// Will be called 3 seconds after level start
void CreateMyInstance()
{
Instantiate(prefab, Vector3.zero, Quaternion.identity);
}
Resources.Load()
or do not destroy the object, HIDE it instead then flip it back on somewhere else.
Delay code in C# :
//Javascript requires something different ..
// read on IEnumerators if you don't understand.
public IEnumerator DoDelay(float seconds, System.Action callback) {
yield return new WaitForSeconds(seconds);
callback();
}
public void MyCallBack() {
//this gets called when DoDelay is ready. can instantiate here or whatever.
}
void StartDelay() { //call this in your calling function...
StartCoroutine(DoDelay(3.0f,MyCallBack));
}