Search Unity

Particle Systems in 2d above all sprites (Custom Axis sorting order)

Discussion in 'General Graphics' started by nicmarxp, Jul 21, 2019.

  1. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    I'm using a Custom Axis for the Transparency Sort Mode and it's set to 0,1,0 so sprites in my top down game gets sorted by the pivot point in the Y axis.

    However particle systems seem to ignore this, and is sorted by Z-axis instead.

    See the GIF below, where the particle system show in front of a rock, even if it's higher up in Y axis and should be behind the rock. In the GIF I change the Z-axis on the particles, which also makes it come behind the background, which is incorrect.

    Does the Particle System Renderer module not obey the Transparency Sort Mode?

    How are we supposed to use particles in a top down game like this?

    I think my question is somewhat similar to this one, but I couldn't find any solution to my problem:
    https://forum.unity.com/threads/particle-systems-with-sprites-order-in-layer.464533/

     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Particles are sorted based on distance to the camera, and don’t prioritise any particular axis.

    You’re right that we don’t use the Camera’s transparency sort mode for sorting particles within a system.
     
  3. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    I see! How would I do to make them come behind certain objects in a 2d game then? :)
     
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Actually.. I may have misunderstood your initial post. You weren’t referring to sorting particles within a system were you? But rather, sorting a particle system and a sprite?

    In this case, transparency sort mode should work correctly.

    If you suspect it’s not, you may need this submit a bug report.

    Sorry for my confusion!
     
  5. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Yeah the particles are supposed to come between the background and a sprite. I got a tip to check the particles in 3D mode to see how it looks.

    Also I will disable noise/movement in the Z-axis and hopefully it will work :)
     
    richardkettlewell likes this.
  6. LoneXUnity

    LoneXUnity

    Joined:
    Mar 24, 2020
    Posts:
    7
    I have the same problem please share how you solved it.
     
  7. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Ohh it was a long time ago and I’m not sure I solved it, but I think the reason was the particles spawned in a random Z (depth) position. Check in 3D view from the side if thats the case. Let me know if it works!
     
  8. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    You should be able to set the scale z in the shape module to 0 to solve that
     
    hellobody and nicmarxp like this.
  9. StiryMixy

    StiryMixy

    Joined:
    May 5, 2021
    Posts:
    7
    Hello, I am also experiencing this issue with an isometric grid based game:

    The particles are appearing in front of sprites that they shouldn't.

    Is there like an option to sort by Y each particle?
     

    Attached Files:

  10. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    There doesn’t seem to be, they seem to be sorted in it’s own sorting group. If you figure it out, please share :)
     
  11. Andrew_M741

    Andrew_M741

    Joined:
    Oct 20, 2020
    Posts:
    1
    I'm having the same problem if you know how to fix it.

    edit:

    i sort of got it working but is there a way to set the sorting/pivot point to the position of the emitter/game object?
     
    Last edited: Jul 14, 2021
  12. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Hi, I'm not sure if you already got the answer after all this time but I just wanted to post something that I do and might be a solution for this problem because I found this thread after somebody asked me about the same exact problem.

    For 2.5 or for using Particles interacting with Sprites that have a 3D-like perspective you should use a custom material instead of the Default-Sprite one because Sprites and Paticles have their own sort order, and in the case of Particle Systems, they are sorted by System and not by individual particle (as I understand).

    So I create a material for my Sprite using the Standard Shader if you want to receive lighting, or if you want it to be Unlit you could use a self illuminated shader like the Legacy ones:

    upload_2021-8-17_23-32-14.png

    upload_2021-8-17_23-33-26.png
     
    april_4_short likes this.
  13. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Awesome, thanks for sharing this. It looks great! So if I understand you correctly, when using your own material the particles sort correctly? Is that the same material and shader on the particles and the sprite?
     
  14. blekkh

    blekkh

    Joined:
    Feb 14, 2019
    Posts:
    19
    Hi guys, is there now a way to sort each individual particle based on the y axis? Cant find anything about it till today.. :(. The following post couldnt fix my issue.


    Thanks for any help.
     
  15. d2king10

    d2king10

    Joined:
    Dec 21, 2009
    Posts:
    53
    I know this is a bit of an older topic but I ran into the same thing today and figured out a solution. I wanted some water to drip from the ceiling of my top-down RPG and wanted the water drips to sort on top of things when higher up but behind when they got close to the ground. I solved this by having my particle system emit from a line and positioned it where I want the drops to start. This particle system is inside of another object that has its pivot set to the spot where I want the particle system to actually sort. I then added a Sorting Group component to the parent object and that forced unity to use the parent ground pivot for sorting against my 2d sprites.

    upload_2023-8-23_13-54-44.png