0
\$\begingroup\$

I have a particle system, and my character, which is a sprite. I want to create a particle for smoke/dust raising from the ground, and I want my character to be able to move over it.

The problem is that the particles are all drawn in front or behind the sprite, even if the sprite is in the middle of the smoke:

If I move the sprite a little forward, all the particles are behind:

It's like all particles are sharing the same Z order of the particle system itself.

I have been facing this problem from a long time, and I tried using other shaders, new sorting layers, and messing with the particle system fudge, but the result is always the same.

I want the particles to be rendered in the correct order, those that are further away, behind the character; and those closer, in front of the character.

Any idea of what is happening here?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

It is the case that all particles share the same Z order in unity. This is a weird design choice, but I believe it 's because the emitter is an object that is sorted with the rest of the world, and does its own internal sorting for particles. (You also cannot mix particle systems).

One way to handle this is to have two particle systems, one behind and one in front.
See https://www.youtube.com/watch?v=0IrCggoJCno for an example

\$\endgroup\$
2
  • 2
    \$\begingroup\$ While it's true that all particles in one particle system share one place in the draw order, it may be misleading to say they share the same z order since they will be correctly occluded by objects that write to the depth buffer. The trouble here is that the default sprite material does not write depth. We can change that to sort opaque parts of sprites correctly, but it can lead to artifacts in places where edges have a soft alpha falloff. \$\endgroup\$
    – DMGregory
    Commented Oct 20, 2016 at 0:06
  • \$\begingroup\$ Really informative video. Nicely explained! \$\endgroup\$
    – Leo
    Commented Oct 20, 2016 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .