Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Which will be better, a single FixedUpdate with complex code or many FixedUpdate with simple code?

Discussion in 'Getting Started' started by narf03, May 3, 2015.

  1. narf03

    narf03

    Joined:
    Aug 11, 2014
    Posts:
    223
    Title said it.

    Lets say i will need to have like 100 moving GameObject in my scene, i need to move them in my code. I can have a manager that manage a full list of these 100 items, and only perform their movement in 1 single FixedUpdate with complex code, or perform it separately into 100 FixedUpdate with much simpler code(attach to each GameObject) ?
     
  2. jhocking

    jhocking

    Joined:
    Nov 21, 2009
    Posts:
    814
    There isn't exactly a right or wrong answer here, but the latter is usually how you want to go. Usually; there are plenty of times where it makes more sense to control a bunch of objects in one manager script. Either approach works fine, so just do whatever makes the most sense, bearing in mind that simpler-to-understand code is almost always better in the long run (so that others can understand what you wrote, and so that you can understand what you wrote 5 months ago.)