Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Terrain objects are on the wrong layer

Discussion in '5.4 Beta' started by makeshiftwings, Jul 16, 2016.

  1. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    So, I reported this bug a while ago but it was closed as "by design" and I didn't get a further response, so I'd like to post it here and get a second opinion. The bug:

    Terrain objects, like trees, do not properly inherit the Layer of the terrain they are on. For most things, including Camera culling, physics collisions, and getting the component's layer by code, it returns the Terrain's layer. But for Raycast layer masks, they act as if they are on whatever layer was set in the tree prefab. Original dev response was that this was "expected behavior", but I think that's kinda ridiculous. Raycasts should use the same layer assignment as every other aspect of Unity; it doesn't make any sense for there to be a single exception to how layers work that is not documented anywhere. This is doubly important for SpeedTrees since I can't figure out a way to actually change the layer that their prefab is on, since it is set to "Default" and greyed out.
     
  2. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Anyone want to chime in? Other users even? Getting this fixed would really help my project, so if there's a reason that this is intended behavior or anyone relies on it working this way I would be interested.
     
  3. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    i can see why you are saying this, but maybe you could write your own class to work as a secondary layer? Just suggesting a workaround - or use tags, or are they also inherited?
     
  4. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I can work around it, currently by changing my Raycasts against a single layer to RaycastAlls against all layers and then searching the returned colliders' layers for the one I want. But this is a performance hit when it would be simpler to use a Layer Mask instead.