Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Line Renderer And 2d Isometric Sorting

Discussion in '2D' started by mikapote, Apr 12, 2019.

  1. mikapote

    mikapote

    Joined:
    Oct 24, 2018
    Posts:
    28
    Hey everyone! Quick question: did someone already succeed to have part of a line renderer be drawn in front of an object, and the other part behind...?

    Here is a concrete example in the image below: the left hand side of the image shows what is happening today, and the right hand side, what I want.

    upload_2019-4-12_17-33-56.png

    What happens now is that the whole line is first drawn on top (as pictured above, on the left) and then suddenly drawn behind (not shown here), when its pivot's Y position (center of mass) is greater than the object's Y position. The only hack I'd see for now, is to split the obstacle in two sprites: the upper part that would always be drawn on top of the line, and the bottom part that would always be drawn behind.

    Do you know if it is the only way, or if there's a cleaner way to achieve this? Thanks!
     
  2. beanie4now

    beanie4now

    Joined:
    Apr 22, 2018
    Posts:
    311
    Either use a mask or divide the column into 2 parts. Slicing the column right above the green bar seems like a good bet.
     
  3. mikapote

    mikapote

    Joined:
    Oct 24, 2018
    Posts:
    28
    Thanks Beanie. Yep, I'll probably go with slicing my sprites into 2 parts... until maybe one day the Unity team allows sorting line edges individually, according to their Y position :)