Search Unity

Static Game Objects - Explanation Please

Discussion in 'Editor & General Support' started by Zktchr_0, Jan 3, 2019.

  1. Zktchr_0

    Zktchr_0

    Joined:
    Jul 2, 2018
    Posts:
    1
    Hi,
    In the inspector, as you probably know, there's for each game object the static option, right next to its name.
    I haven't seen any tutorials or found posts talking about it and the page in the manual doesn't say that much.

    I was trying to understand stuff about static\dynamic colliders (eventually found out it doesn't matter much after Unity 5), and understood that unity knows automatically whether a game object is static or dynamic (if it has a ridigbody attached).
    If it's automatic, what's the use of this option? And if it's meant for other stuff, what's the correct way to use it?

    For example: In my scene I have lots (but less than 100) of non-moving objects, yet they become transparent if they stand between player and camera. Is there any advantage to mark them static? Any specific option there is preferred for this case over another?...
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    It can be from advantage, but depends on the project. If it's about performance, you should profile your game.

    The static flag affects how systems in Unity process/handle this object. For example, your game might or might not run faster if you turn on Static Batching. If you use light mapping, Unity bakes light for static objects only.

    The static flag not only affects the physics system.You find links to each affected system in the "Static Settings" sections in the manual, in case you didn't find it yet:
    https://docs.unity3d.com/Manual/StaticObjects.html
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    Generally if your object is not going to move, its highly likely setting it as static will give you a bit of a gain, but as @Peter77 said you have to profile, even if you have two projects that are identical, things can be different between them at a profiler level check.

    Best thing is profile everything, then set them all to static and profile again and compare the graophs