0
\$\begingroup\$

So Update is called every frame while FixedUpdate is called on Physics time, which can be modified.

Is it better to depend on FixedUpdate to have optimized game loop so that everything doesn't get called so much.
OR
Is it better to write a coroutine to Update/FixedUpdate and set things there?

public void Start(){
   StartCoroutine(MyIntervalMethod());
}

 void MyIntervalMethod(){
   for(;;){
   yield return new WaitForSeconds(.2f/*or whatever time interval is suitable here*/);
   }
}
\$\endgroup\$
2
  • 3
    \$\begingroup\$ The reason that all three of these tools exist is that each one is used to accomplish different tasks. If just one was "better" overall, Unity would deprecate the other methods so everyone would know to always use that one. Can you give us a bit more context on the specific behaviour you're crafting right now? If we know in detail what you're trying to accomplish, we can recommend appropriate ways to accomplish it. \$\endgroup\$ Commented May 24, 2020 at 13:06
  • 2
    \$\begingroup\$ I second what DMGregory says, but also want to point out that the code you posted will start the coroutine over and over every frame, which is almost certainly not what you want. \$\endgroup\$ Commented May 24, 2020 at 14:10

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.