Unity2D Sorting Layers with Particle Systems

Hey Everyone,

I have a problem here that’s very frustrating, and I’m thinking (hoping) it’s because I’m doing missing something very obvious. I’m using Unity2D and I have a particle system. The problem is simple - The particle system runs and works, but the particle system displays behind every single gameobject. No matter what I do, I can’t get it to display in front of any sprite. In fact, it is even hidden behind the background.

In case you are saying to yourself, “This question looks familiar”, you are right! It’s been asked (and answered), but I have not been able to find a solution that works for me. The main solution I have found is to change the sorting layer name of the Particle-System. I have done that, but it does not work. Here is my code:

this.GetComponent<ParticleSystem>().renderer.sortingLayerName = "Enemy";

Does anyone have any ideas?

Thanks!

NOTE: I am using a Shuriken Particle System

1 Like

I think i got it. Go to renderer in your particle system and change Order in Layer to amount u need. Works for me perfectly.

82354-screenshot.png

I finally debugged the issue and have come up with a workaround (though, I’m not really sure what the exact cause is. I think it might might actually be a bug in Unity.
Anyways, it deals with the SpriteRenderer and the order in which it is applied to the gameobject (relative to the Particle System)…In my case, I was trying to apply a particle system to a gameobject that already had a SpriteRenderer component attached to it. For some reason, this eliminates any possibility of putting that Particle System in any sorting layer other than the one that is furthest back. The workaround I found was to remove the SpriteRenderer, and then add it (or just create a whole new gameobject and add the Particle System first). After doing this, I was able to change the sorting layer of the particle system.
Another workaround would be to create a separate particle system gameobject and attach it (as a child) to the main gameobject.

I know this is an old thread, i’m putting a work around here:

Alternatively, you can specify when your particle system has to be rendered. You can check the particle systems rendering order in frame debugger and if you want to push it front, you can increase renderqueue value by increasing the Custom Render Queue value.

I had a similar issue with Canvas where particles would render above my UI, even if I put the particle system at a sorting layer that was under the UI.
I solved this by changing the sorting order layer on the canvas to 1 instead of 0.

I’m not sure if a similar solution would work for Sprites.

Changing the X Rotation to 180 worked for me

119958-untitled.png

Try changing Z position)

Came here looking for an answer to the same problem. Sorting Layers seemed to have no effect on the particle system.
i was trying to use a Cone shaped particle system emitter, but that cone was pointed away from the Main Camera. i flipped the cone 180 degrees on the Y-axis, so the particles are emitted towards the camera. Now, it works just fine.

Everyone is showing screenshots of the “Renderer” component (to change the sorting layer) but I have no idea what they’re talking about, as the Particle Systems don’t come with a Renderer component by default.

In Unity 2022 or higher, how do you change the sorting layer of a Particle System?