Particle System rendering behind Sprites

I’m trying to use a particle system with my 2d project.

I have it placed on a higher z-index and can see it when the particle systems materials shader is bumped diffuse, however when I change it to something like unlit/transparent it will always render behind the sprites regardless of what the z-index of the particle system is.

Since there isn’t many resources on working with 2d in 4.3 is there something I don’t know about particle systems or the new 2d stuff that is causing this issue?

Not sure if this was in Unity 4.6, but in Unity 5, go to your particle’s Inspector, expand “Renderer” and you should see the fields “Sorting Layer” and “Order in Layer” (close to the bottom). Select the sorting layer that you wish the particles to appear on.

This fixed my issue (particles appearing behind background) and hopefully it’ll fix yours.

Figured it out. It seems odd you have to go this far but here’s the solution.

On the Particle System object you’ve created, create a C# script and name it “ParticleSortLayerScript” or whatever else you want to call it. You can also add this into your code if you have a script attached but make sure it gets added to the Start() method.

Now you have to manually code in what layer you want the particle system to apply to. It seems that by default, the particle system gets sent behind every other layer, which is why you have to force it to be in a layer in front for the camera to see.

Code to do this is:

	void Start ()
            //Change Foreground to the layer you want it to display on 
            //You could prob. make a public variable for this
            particleSystem.renderer.sortingLayerName = "Foreground";

Note that for my project Foreground is the name of the layer I want my particles to display, but yours may be different. If you dont know what I mean by Layer, I’m talking about sorting layers. On the Top right of the Unity Editor you should see a drop down called “Layers”, click this to see the layers in your project. You can add additonal layers if you like as per Unity - Manual: Layers

I encountered a similar problem but for seemingly entirely different reasons. The problem was made clearer when I switched from viewing the scene in 2D to 3D. The issue was that that particle system was emitting the particles AWAY from the camera, and thus behind all of the other sprites in the scene.

My solution was to set either the X or Y rotation to 180 degrees.

Edit: Oops. I replied twice. I couldn’t see that I had replied, and just assumed the website ate my comment.

I just ran into this same issue, and swore up and down it was sprite-related, since that was the last thing I added to my project.

However, I just realized I’d been calling Play() and Stop() on every Update() cycle, rather than just once and letting them do their thing.

This was also causing my particle system to fail to start (unless it started pre-warmed for some reason).

Just a thought, if someone else stumbles into this thread and can’t get the above green-answer to work for them.

It seems that particles like to be seen in the 0 sorting layer, so what i have done is put my 2D content in -1,-2 layers, this should fix your problem

I had the same problem and in my case it turned out to be because the particle system was pointing away from the camera in 3d space which made the particles shoot out behind the background. I rotated the GameObject the system was attached to by 180 degrees around the Y axis and that fixed it for me.

I come up with the same problem. And the particle’s sorting layer solution works while the particle material’s render queue does not. Unity documentation says, Sorting Layers are used in conjunction with sprite graphics in the 2D system. So why it works with particle? And what’s the difference between sorting layer and render queue?

After tinkering with the sorting layers, I have found that the reason it is coming up this way is because particles are on the default layer. There are two methods you can do. There is the manual way (that Stone Legion has already posted) or you can move your default layer to a higher position via Edit->Project Settings->Tags & Layers and adjust the sorting layer from there. Depending on your approach, this may be a quicker fix if the particles are the only thing using that layer but I personally prefer control and use the manual method.

I am surprised that layer solution works because in my case, it doesn’t work. What works for me was instead of displaying the image as sprites, I used the image as texture. This fixes the issue for me.

I created three cameras for my game. The Main Camera for sprites. A Particle Camera for particles. And a UI Camera for UI elements.

The Main Camera has a culling mask for all layers except UI and Particles(user created layer) and a depth of 0, the Particle Camera has a culling mask of only the Particles layer and a depth of 1, and the UI Camera has a culling mask of only UI and a depth of 2. By changing the depths of the cameras, it allows particles to be on top of sprites and the UI to be on top of particles and sprites.

Of course, all particles are on the Particles layer and all UI elements are on the UI layer. It is important to make sure all of your particles’ Z transforms are within the camera’s view. I set mine at -5.

All cameras are Orthographic and have the same transform position(5,3,-10). The Main Camera has a Clear Flags of Solid Color with a black Background. The other two cameras have Clear Flags of Depth Only. Only the Main Camera has an Audio Listener.

Maybe this was a fix from 4.3, but in 4.6 while using Mobile/Particles/Alpha Blended shader, you can instantiate the particle system at a negative Z value (I.e., 0,0,-0.1), and this draws the particles over the sprites.

Well in Unity 5.3 , there is no need for attaching any script. SortingLayer property is already exposed under Render tab of ParticleSystem

I have another simple solution what can help you without any code required. You just need to put “1” to settings “Order in layer” of Renderer settings of the particle system like attachment image.72484-order-player.jpg

For me it worked in Unity 5.3 with that code

void Start () {
GetComponent().GetComponent().sortingLayerName = “Player”;
GetComponent().GetComponent().sortingOrder = -1;

none of these solutions works for me ,
the following is useless because it already exists in the UI so whats the point of having it as a script
sortingLayerID = spriteRenderer.sortingLayerID;
.sortingOrder = spriteRenderer.sortingOrder;

also this is no longer available in unity particleSystem.renderer.sortingLayerName = “Foreground”;

nothing works anyone any workaround?

If anyone is looking for its answer , follow the first answer of this link.