- Home /
Coroutines or InvokeRepeating
Which one of these would you recommend if you would have something happen every second:
1. Start a coroutine in Start() and use while(true){ yield return new WaitForSeconds(1f); } in the coroutine
2. Start a coroutine in Update() and not use while(true)
3. Use InvokeRepeating
Is anyone more performant than the others, or better practise? Is while(true) a bad way to make something happen over and over again?
Thank you!
Answer by jdean300 · Dec 30, 2017 at 06:59 PM
InvokeRepeating will tend to be faster but you have slightly less control over it - you can't yield with the called function and can't cancel individual invoke calls. Go with InvokeRepeating at first. If you end up needing coroutine functionality later it is not hard to change to it.
Your answer
Follow this Question
Related Questions
InvokeRepeating VS Coroutines [Performance] 1 Answer
Coroutine in place of InvokeRepeating in need of start at time parameter 1 Answer
Pause GameLoop with Pause Button 1 Answer
How can I get my platforms to randomly appear when not activated by button 1 Answer
How to get function to run every x seconds and then every y seconds? 2 Answers