Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Why aren't these sprites rendered according to my z-index?

Discussion in '2D' started by dreamCirno, Mar 14, 2020.

Thread Status:
Not open for further replies.
  1. dreamCirno

    dreamCirno

    Joined:
    May 16, 2018
    Posts:
    20
    All my sprites are in the Default Layer.
    These sprites have different values for each z-axis.
    But I had a problem, when my camera went to the right, the rendering order changed, and then I went back and the rendering order was different.


    PLEASE CLICK LOOK preview picture.
    https://s1.ax1x.com/2020/03/14/8QgX8O.gif


    I wonder what causes such problems?
    Is there a quick and easy way?

     
    Last edited: Mar 14, 2020
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    How different are the z's? Maybe it's perspective camera with very small z's?
    Does orthographic solve it? This isn't a solution b/c you'd lose the parallax effect but that would tell us more info.
    If you use different sorting layers / sorting orders, does the same problem persist?
     
  3. dreamCirno

    dreamCirno

    Joined:
    May 16, 2018
    Posts:
    20

    When I set Order in Layer, the rendering Order was fine, but it was a lot of work because I had a lot of sprites.
     
  4. dreamCirno

    dreamCirno

    Joined:
    May 16, 2018
    Posts:
    20
    Actually, what I want to do is simple. Enables the camera to render sprites in z-index order.
     
    maax223 likes this.
  5. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    What happens if you try to set a Custom Transparency Sort Axis so that it uses front-back according to z? This setting can be accessed through Edit > Project Settings > Graphics.
     
    dreamCirno likes this.
  6. dreamCirno

    dreamCirno

    Joined:
    May 16, 2018
    Posts:
    20
    Thank you very much!!! YOU HELP ME SOLVE THIS PROBLEM!
    This knowledge point is rarely mentioned in Unity tutorial videos.

    I use LWRP in my project. So I found the setting in here.
     
  7. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    Yeah, that's a real "gotcha" feature: not very widely known about. Cheers!
     
Thread Status:
Not open for further replies.