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. Dismiss Notice

Graphics question; hide objects behind an invisible wall?

Discussion in 'Editor & General Support' started by DaleNation, Jul 8, 2014.

  1. DaleNation

    DaleNation

    Joined:
    Jul 6, 2014
    Posts:
    30
    Hello,

    I'm going to have different levels in my game, but for certain reasons I cannot create a separate scene.

    Therefore, I'm simply going to put level 2 right next to level 1. However, because of the level design, while standing on level 2's terrain you can see level 1. Is it possible to put box around the level and make it invisible, but only to the extent that it allows the player to see the skybox and not level 1?

    Like, make it so when the camera looks through it, the camera will only render the skybox and not 3D objects on the other side.
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    You could gather all renderers in each level, into separate vars....

    Code (csharp):
    1.  
    2. public Renderer[] level1Rndrs;
    3. public Renderer[] level2Rndrs;
    4.  
    Then turn either on or off as needed.


    Code (csharp):
    1.  
    2. ///turn off level 1 renderers.
    3. for(int i = 0; i < level1Rndrs.Length; i++){
    4. level1Rndrs[i].enabled = false;
    5. }
    6.  
     
    ElvisAlistar likes this.
  3. DaleNation

    DaleNation

    Joined:
    Jul 6, 2014
    Posts:
    30
    Ah! That post helped me find a better way. I had all the objects for level 1 as the children of an empty GameObject. If I toggle it off, they all disappear.

    Thank you.
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    No problem.

    Good luck!