Search Unity

SpriteRenderer order issue

Discussion in 'General Graphics' started by LunaticEdit, Dec 17, 2017.

  1. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60


    I have a GameObject that has multiple individual pieces making up the character. These pieces are animated and everything was working GREAT. Character properly drew behind and in front of 3D geometry. But then, I added billboard trees and everything went sideways. I see that the trees are rendering at layer order 0, which is why part of the character renders behind, but other parts don't. The issue is, I have to specify rendering order for the player so that his legs/arms/hair/etc render in the proper order. But because the trees are render layer 0, they will be rendered on the batch for layer 0 for ALL draws on the screen.

    Is there anyway to specify 'local order' for a set of sprite renderers? Is there any better way to do ordering of individual pieces of a character without affecting other objects on the screen?

    Any help would be appreciated!
     
  2. LunaticEdit

    LunaticEdit

    Joined:
    May 1, 2014
    Posts:
    60
    OK so I think I fixed the problem. I added a script to every 2d object that checks the z distance to the player and adjusted to -50 or 50 based on if it is in front of the player or behind. Seems to work well if anyone else has the same issue. Doing NPCs will be a bit painful but unless anyone has any ideas I'll just have to figure it out using constant adjustments of these values...

     
    theANMATOR2b likes this.