- Home /
TrailRenderer coexisting with sprites
I've attached a trail renderer to a sprite, and given the trail renderer the Sprite-Default material. It's drawing a nice trail, however the trail is appearing behind all of my other sprites (which includes a background layer, obscuring the trail entirely). Is there any way to change this behavior at the moment?
Lucky! I want $$anonymous$$e to be behind but its showing in front of everything, I don't know how to fix it though so gg
Answer by nickavv · Dec 11, 2013 at 01:49 AM
Figured it out. Renderers (even non 2D ones) do have a sort order property, it's just not exposed in the editor. The following solves my problem.
var tr : TrailRenderer = GetComponent(TrailRenderer);
tr.sortingLayerName = "Character";
Answer by Spinnernicholas · Dec 10, 2013 at 11:48 PM
Move the renderer closer to the camera.
$$anonymous$$ine was fixed with this: firstly, try the following (js) code: gameObject.GetComponent(TrailRenderer).renderer.sortingOrder = 6990; gameObject.GetComponent(TrailRenderer).sortingOrder = 6990;
if that doesn't work, try moving the object containing the trail renderer closer to camera.
Your answer
Follow this Question
Related Questions
trail renderer shows above everything (Unity 2D sorting layer ) 0 Answers
Trail renderer not rendering over sprite background 4 Answers
Trail Render not become visible during game play 0 Answers
TrailRenderer sorting layer problem. 2 Answers
How can I achieve this particular 2D lighting effect? 2 Answers