Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Should empty gameobjects be static, or is "nothing" better?

Discussion in 'Editor & General Support' started by radiantboy, Nov 25, 2022.

  1. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Hey guys... A dumb question from a guy who has used unity for 13 years. But today I was thinking of all the empty gameobjects ive used and how they arent static (and by empty I mean just ones with scripts, audiosource, gizmos etc, no mesh renderer or moving models etc). I have Large deeply nested hierarchies of thousands of waypoints, spawners etc. I checked and these are not static but set to "nothing" which curiously I had never read about, docs say "Do not include the GameObject in precomputations for any systems.". So does that mean all my waypoints etc are slowing things down or not? If I mark them static I feel like it would then be using them in systems that don't require them to be in (like they wont affect gi, navigation, etc etc).

    So is "nothing" better than static for "empty" game objects, ie ones that have no renderer of any kind.

    As a side note I always wondered if you should make animated objects that do not physically move as static? Maybe something like a fan on the roof, its animated and rotates blades but never moves the object itself. Or even canvases, should they be static? Sorry for bundling all this in one :) These are just side questions lol.
     
    protopop likes this.
  2. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    As a strange side test I took the dynamic fluid pack and ran it in my main root scene of my game. Runs about 75fps, this scene holds every single interior in the game, every spawner and every waypoint and every single semi useless game object imaginable (but all meshes are off, and gizmos, its essentially an empty scene visibly). Then I took the same code and put it into my other scene (a small VJ tool that I use in clubs) which is WAY smaller, way less objects (though still some fairly low poly cities turned off), and it ran at 215fps. Both HDRP, same machine (128gig, 12090k 2080rtx) - but the liquid sim flies on the scene without all the "empty" objects. I might be shocked to find that somehow all these objects cost time. I think I actually turn them off when theyre not needed to be honest (each city only has on what is needed) but will need to double check many objects if it makes that much of a difference.

    EDIT: yeah im thinking I could be being dumb because any of these objects could have scripts running, but they basically dont, none of these objects have scripts, nothing shows up in the profiler about them, they arent in use in anyway, but they do exist and are on in my tests. So is looping through the objects a thing maybe? I mean will a scene with 10 million empty game objects nested, be slower than a scene with none, and how noticeably. Hey I can do that bench mark myself, brb.