Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
6
Question by saruul34 · Jan 03, 2014 at 05:41 AM · trailrendererunity4.3sorting layerstrail renderer

Trail Renderer and Sorting Layer problem

It's a 2D game. I have a bullet with a trail renderer and the trail renderer is visible in the #Scene but it isn't visible in the Game screen of the Unity. When I remove background of the game, it shows the trail renderer. So I figured out it's sorting layer problem with trail renderer.

I tried renderer.sortingLayerName and renderer.sortingOrder, but no effect. (It worked on particle system).

How to set sorting layer to trail renderer ? or Is there any alternative way to render trail of the bullet? Thank you.

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 emalb · Jan 05, 2014 at 02:56 PM 0
Share

Thank you. I ran into the exact same issue today and your script has sorted it out for me.

4 Replies

· Add your reply
  • Sort: 
avatar image
14
Best Answer

Answer by saruul34 · Jan 03, 2014 at 05:28 AM

Finally I have sorted it out. (Trail renderer has own renderer, I put there sortingLayerName.) I attached following new script to bullet's parent. And it works as I expected. Whoever has a same problem, try it.

 public TrailRenderer trail;
 // Use this for initialization
 void Start () {
     trail.sortingLayerName = "Background";
     trail.sortingOrder = 2;
 
 }
Comment
Add comment · Show 4 · Share
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 RavenOfCode · Jul 24, 2015 at 04:48 PM 0
Share

Thanks :) Worked Great

avatar image siddharth3322 · Mar 07, 2017 at 01:32 PM 0
Share

I have tried this but I can't able to get success!!! Here is a picture for this...alt text

Here is my code for this purpose:

 private TrailRenderer my$$anonymous$$eshRenderer;
 
     //
     public string layerName;
     public int sortOrder;
 
     void Start ()
     {
         my$$anonymous$$eshRenderer = GetComponent<TrailRenderer> ();
 
         my$$anonymous$$eshRenderer.sortingLayerName = layerName;
         my$$anonymous$$eshRenderer.sortingOrder = sortOrder;
     }

screen-shot-2017-03-07-at-65856-pm.png (177.4 kB)
avatar image nipunasudha · Jul 24, 2018 at 08:06 PM 0
Share

You can change sortingOrder and sortingLayer in the trailRenderer component from the inspector too.

avatar image siddharth3322 nipunasudha · Jul 25, 2018 at 08:23 AM 0
Share

yes you are right but this kind of feature become available later on before this kind of functionality not exist in Trail Renderer component.

Also trail renderer shader type also important, all shaders are not compatible with trail renderer.

avatar image
8

Answer by LocalNoob · Jul 14, 2018 at 02:35 PM

Make sure the material of your trail renderer has a shader of type Sprites/Default, otherwise sorting layers wont work

Comment
Add comment · Share
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
2

Answer by jpdodson42 · Feb 09, 2018 at 06:54 AM

Just to add onto this thread in case somebody else comes across it. It seems like there are a number of problems you can encounter when adding a trail renderer to a sprite and not having it display.

Eventually I found out what was going on in my case. I was adding a trail renderer to a sprite that was (obviously) on a canvas. The canvas property "Render Mode" is by default set to "Screen Space - Overlay", but if you want to display a trail renderer, the canvas needs to be able to see it. Having the canvas set to this mode "blocks" it. You can change the canvas "Render Mode" to "Screen Space - Camera" instead, and that should do the trick.

Adding this in case somebody else has the same issue I was having.

Comment
Add comment · Share
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
0

Answer by Gunorgunorg · May 12, 2017 at 05:28 PM

I don't know if this still matters because the question was 2 years ago, but it was the top spot when I googled this issue before finding a solution on my own in Untiy 5.

When changing the order in layer you can change the sorting layer as well. So make a new layer and put it above the "Default" layer on the list. Then mark any objects you want the trail renderer(and object creating the trail) on the "Default" Layer and other objects in the other layer.

PS This is the same way I solved text going behind sprites as well just in case that issue arises as well.

Comment
Add comment · Show 1 · Share
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 savantedroid · Aug 28, 2018 at 07:28 PM 0
Share

I did the same but no luck. $$anonymous$$ine always renders on top of everything. What material are you using with your trail renderer?

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.

Follow this Question

Answers Answers and Comments

27 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

Related Questions

Use trail renderer for path following? 2 Answers

Trail Renderer Fade Out on Button Press 0 Answers

Black Trail Rendering in 2D game 1 Answer

Fixed size trail renderer 1 Answer

Trail Render not become visible during game play 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges