Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Static check box for Sprites

Discussion in '2D' started by cstlmode, Nov 29, 2016.

  1. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    hello ,
    i'm working on 2.5 d game , i have significant amount of sprites which are causing some performance issues, some of those sprites are with collision some of them are not , i read somewhere that GameObjects with collision but no Rigid body are considered static ,so does checking the static check box have impact on performance or not in both cases
    please need some light i'm new to this
     
  2. BlueSin

    BlueSin

    Joined:
    Apr 26, 2013
    Posts:
    136
    Any object that doesn't move in your scene would be considered static. By checking the static checkbox this causes objects of the same type to become "batched", which will improve performance. Think of it as the engine basically saying okay, all objects of this type are the same so I don't need to go through each one and do special processing of any kind. So I'll just quickly throw all these up here and move on to the next task.
     
    cstlmode likes this.
  3. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    thanx alot BlueSin for the reply , so i have to check that static checkbox ,for every gameobject that will not be moved either it has collision or not , is this right ?
     
  4. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    also i have another question ,
    is it fine to have a non static GameObject as child of a static parent
    parent have a collider and child have a collider and RB
    thanx alot and sorry for too much questions
     
  5. BlueSin

    BlueSin

    Joined:
    Apr 26, 2013
    Posts:
    136
    Static game objects cannot detect anything for collisions. True collisions are handled by the physics system and require at least one rigidbody. In theory, anything that moves in your game project should have a rigidbody attached to it. Anything that will not move should be static. Now that's not to say you can't have a collider on it. Although you could use SendMessage to communicate with the collided static game object from the rigidbody object.

    As to your next question of a child object with rigidbody attached to a static parent, I think that should work out just fine. I haven't ever done it personally and I don't have access to Unity right this second to check, but if you can toggle the static check box on the child and it isn't locked to static because the parent is static then I would say yes you can.
     
    cstlmode likes this.
  6. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    thanx alot BlueSin ,that helped me alot