- Home /
Incorrect draw order with LineRenderer
Hello!
I have a Player game object with a sprite renderer and a line renderer.
The sprite for its body and the line for a rope.
The problem is that the rope isn't visible (I can see it's drawn in the scene but not in-game).
I can also see the rope if I disable the background.
I have the following sorting layers (in this order):
Background
Platforms
Default
I have tried multiple combinations of sorting layers and other ordering attributes but the current one is:
Sprite Renderer is in the Default sorting layer with an order in layer of 1
Line Renderer is also in the Default sorting layer with an order in layer of 0
The background game object has a Tilemap Renderer in the Background sorting layer with an order in layer of 0
This combo worked with no background, but with it, the line is gone. The values of order in layer were tweaked so the line would be drawn behind the sprite and that worked.
The line positions all have a z value of 0. If I change it to a negative value (say, -0.1f) the line gets drawn on top of everything (even the sprite, which I don't want). I could probably offset the player position in the z axis, but that could mess up some calculations.
Thanks in advance to anyone who's willing to help!
I found a workaround: add a little z (0.0001 was enough) to the background. Still don't understand. If there's a cleaner solution, I would like to hear it!
Your answer
Follow this Question
Related Questions
LineRenderer Objects Covers UI Objects 0 Answers
Sprites render before UI when starting game first time 1 Answer
Line Renderer not working at all with Layer and Culling Mask when created in script 0 Answers
Trouble with mesh rendering order 0 Answers
Mecanim hand IK with bodyWeight problem 0 Answers