Search Unity

How to hide certain objects from the camera?

Discussion in 'Scripting' started by Jonhas, Sep 20, 2019.

  1. Jonhas

    Jonhas

    Joined:
    Jul 28, 2019
    Posts:
    46
    The title is self - explanatory, I'm kind of rushing and Unity Answers isn't very active so, how to hide certain objects from the camera?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The easiest way is with the camera's culling mask.

    https://docs.unity3d.com/Manual/Layers.html

    Set the objects you want to hide to a specific layer, and disable that layer from being shown on the camera.

    For example, in my game I represent objects on the minimap with different shapes, such as ships are triangles. I literally just have a giant floating triangle above each ship. The main camera though has my Minimap layer disabled, so you don't see the floating triangle. The minimap camera's culling mask just includes my Minimap layer and my terrain layer, so all you see is the terrain and the triangles, etc, etc.
     
    xofreshxo, Apposl and Kurt-Dekker like this.