Search Unity

Camera Culling Mask issue

Discussion in '2D' started by Cal2000, Apr 5, 2015.

  1. Cal2000

    Cal2000

    Joined:
    Feb 18, 2015
    Posts:
    11
    Hello,

    I have two cameras in my game, one for the background then the other camera is the main game camera which is basically centred onto the screen (see image below). The main game camera only covers the game. My problem is, as you can see from the image below that with my other depth camera the terrain still overlaps. I want the green hills to only appear when it enters the blue box not over the footage.

    I have my culling mask for my background to only show the background, and the main game camera to cover everything else however this doesn't seem to work. The background camera is set to Skybox with a depth of 0 and the other camera which shows the game is set to depth only with a depth of 1.

    Thank you for your time and help!

    terrain.png
     
    Last edited: Apr 8, 2015
  2. Cal2000

    Cal2000

    Joined:
    Feb 18, 2015
    Posts:
    11
    bump.
     
  3. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    If I am reading your post correctly, is the area I marked on the image is what you don't want to show?

    If that's the case, there are several ways you can do it eg

    1. Why not place the green terrain in the same camera?
    2. Set your second camera's viewport to clip away the regions you don't want to show
     

    Attached Files:

  4. Cal2000

    Cal2000

    Joined:
    Feb 18, 2015
    Posts:
    11
    The position of the black boxes are correct, that's the area I don't want the hills to show at and I want to keep the footage at both sides of the game so clipping wouldn't solve this problem?

    The image below I placed black boxes around the areas I want to keep in the camera's view. In those areas is where I don't want the hills appearing.

    terrain.png
     
  5. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Why not set the terrain layer to the game camera? Is this what you are trying to achieve?

    upload_2015-4-9_13-47-46.png
     
    Cal2000 likes this.
  6. Cal2000

    Cal2000

    Joined:
    Feb 18, 2015
    Posts:
    11
    Yeah that's what I'm trying to achieve and I have set the terrain layer to the Game Camera yet it appears it still doesn't seem to work.

    The Game Camera is the depth camera with a value of 1 which contains all the game content and the culling layer mask contains each game content layer. This camera has a size of 18.

    The Main Camera only has the Video background in the culling layer mask and has a size of 20.

    Just noticed I believe it's using the Game Camera as the Main Camera which is why it's going off. How would I set the Main Camera to be the default?
     
    Last edited: Apr 9, 2015
  7. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Hi

    Try tweaking the Viewport Rect in your game camera. This should give you the clipping that you want. Eg
    x = 0.25, y = 0.25, w = 0.5, h = 0.5
     
    theANMATOR2b and Cal2000 like this.
  8. Cal2000

    Cal2000

    Joined:
    Feb 18, 2015
    Posts:
    11
    That seems to be working! Thank you!
     
    Last edited: Apr 9, 2015