How to draw two lines at the same time that keeps overlapping each other?

Hi,

I want two different lines to be drawn at the same time where one line overlaps the other line when it passes through it.

In the image below I have two different sprites bouncing around the edges of the screen, each with its own Trail Renderer. Here, the green line is always drawn below the red one but I want it to be drawn over the red line when it passes through it. For example, in the bottom of the image I want the green line to be over the red on because it recently passed through it.

If I change the layers or Z-values it’s always one line that is below the other one in all places.

It doesn’t seem like I can solve this with a Trail renderer or a Line renderer, any thoughts on what I can do to solve this?

Assuming your photo is exhibiting the wrong behaviour as its the default one you are describing to be wrong. Then you could just render the paths in segments instead.


If you are more clever then you can before rendering each line segment get all intersections and evaluate if they should be on top or below. But you should be able to rely on render order if you are just trying to stack them.