1
\$\begingroup\$

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 none worked. 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 (before the background) in such a way that 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!

\$\endgroup\$
  • \$\begingroup\$ "I could probably offset the player position in the z axis, but that could mess up some calculations" Then you probably want to fix those calculations. LineRenderers use z-sorting, so this is likely to be the quickest route to the visual you want. \$\endgroup\$ – DMGregory Mar 13 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.