sir how to settimeout ienumerator call every 3 second on runtime? So every 3 second will call same ienumerator function. Thanks
void Start()
{
StartCoroutine ("loopingDelay");
}
IEnumerator loopingDelay()
{
yield return new WaitForSeconds (3);
StartCoroutine("loopingDelay");
}
make sure you only initialise it once not every frame.
1 Like
Is this good to make function like this on every game object?
I have 10 game object and i try to run that class on every game object.
yes thats should be fine as long as its in start() or some other method that is only called on one frame. if in update() it will start the coroutine every frame and defeat the purpose of the delay.
1 Like
Start can be a coroutine itself
IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(3);
DoSomething();
}
}
1 Like
oh thank you for the explaination sir very helpful for me