Search Unity

Not rendering objects after a certain distance?

Discussion in 'Editor & General Support' started by frogwise, Aug 29, 2018.

  1. frogwise

    frogwise

    Joined:
    Nov 27, 2009
    Posts:
    103
    How can I make objects not render and/or computr after a certain distance?

    I have some fish in a lake using navmesh, and to optimize I'd like to not render them after a certain distance. It would be great if the navmesh for the culled fish would also not compute to further optimize .

    I tried using lodgroup but the fish are still visible.

    Thanks in advance!
     
  2. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    On your camera change clipping planes and the far one. Reduce the number to the distance you want. The number equals one unit in Unity which is usually one meter. So set it to 50 and it will render out 50 meters. Play around until you get the distance you like.
     
    reggie5538 and fariddhessami like this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you want everything to stop rendering after a certain distance, you do that with the camera's far clipping plane setting. If you want only certain objects to stop rendering at a specific distance, but you want to keep rendering other objects farther, you use layerCullDistances. To do that you set the far clipping plane to the distance of the furthest object you want to render, you set the objects you want to stop rendering closer to their own layer, and you set the cull distance for that layer to that shorter distance.

    https://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html
     
    xtinacs, MRC-UA, Chill_Crow and 2 others like this.