Unity2D Sorting Layers with Particle Systems
Asked Answered
N

9

1

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

Needless answered 10/3 at 22:25 Comment(0)
H
0

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

Hairpiece answered 5/7, 2023 at 14:17 Comment(5)

This solved for me.

Gehrke

Thank you, I never would have solved this on my own.

Barbarian

Thanks a lot!! really helpfull =)

Noninterference

Unfortunately, this doesn't work in my case. For some reason, it won't take on that sorting layer unless I remove the SpriteRenderer and add it back (as mentioned in my answer). In general, though, this solution is the correct way to sort a particle system.

Needless

lol im so blind i didnt see the there is order in layer there

Kenwood
N
0

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.

Needless answered 6/6, 2023 at 2:41 Comment(1)

Yes, that solved my problem! Thank you very much!!

Bier
H
0

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

Hairpiece answered 5/7, 2023 at 14:17 Comment(5)

This solved for me.

Gehrke

Thank you, I never would have solved this on my own.

Barbarian

Thanks a lot!! really helpfull =)

Noninterference

Unfortunately, this doesn't work in my case. For some reason, it won't take on that sorting layer unless I remove the SpriteRenderer and add it back (as mentioned in my answer). In general, though, this solution is the correct way to sort a particle system.

Needless

lol im so blind i didnt see the there is order in layer there

Kenwood
F
0

Try changing Z position)

Ferromagnetism answered 1/4, 2016 at 14:14 Comment(0)
S
0

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.

Scrogan answered 6/6, 2023 at 2:29 Comment(0)
P
0

Changing the X Rotation to 180 worked for me

Probability answered 31/8, 2016 at 7:55 Comment(0)
I
0

119958-untitled.png

Ity answered 6/6, 2023 at 4:10 Comment(0)
P
0

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.

Pedal answered 10/10, 2018 at 12:16 Comment(0)
L
0

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.

Launcelot answered 6/6, 2023 at 4:14 Comment(1)

Thank you!!! Nothing else seemed to work but this did.

Nunuance
N
0

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?

Nemesis answered 10/3 at 22:21 Comment(1)

the Particle Systems don’t come with a Renderer component by default. Yes it does. scroll down the particle system inspector.

Broth

© 2022 - 2024 — McMap. All rights reserved.