Search Unity

Problem with Trail Renderer's sorting layer

Discussion in '2D' started by hussain0305, Feb 20, 2019.

  1. hussain0305

    hussain0305

    Joined:
    Jun 1, 2017
    Posts:
    15
    I'm making a 2D game and want to have my bullets leave a small trail behind them. I attached a trail renderer component to the bullet's GameObject and the trail shows up in an empty space, but it doesn't show up above the background, even though I'm setting the sorting layer correctly (The bullet's sprite and the trail renderer have the same sorting layer. Bullet shows up in game, trail doesn't). I'm reading on the internet that you're supposed to set the Canvas to Screen Space- Camera but it doesn't make much sense because I'm not trying to do this on the canvas. How do I set it up? Any solutions or a nudge in the right direction is greatly appreciated. Thanks!
     
  2. ManiaCCC

    ManiaCCC

    Joined:
    Aug 15, 2015
    Posts:
    41
    It's material issue. Default line material, as far as I know, is writing depth, which means, sorting layer has no effect on it. You have to write your own shader, or quick fix could be using one of the particle materials already in unity. Try default particle material if this will change things.
     
    hussain0305 likes this.
  3. hussain0305

    hussain0305

    Joined:
    Jun 1, 2017
    Posts:
    15
    Thanks! that did it.