• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Rendoir · Mar 12 at 11:06 PM · layerslinerendererordering

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!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rendoir · Mar 14 at 11:54 PM 0
Share

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!

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

103 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

What is the purpose of layers? 3 Answers

Check if Layer is in Layermask? 4 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges