I was wondering what the correct way to render particles behind game objects. Looks like by using the default particlefx material, particles are rendered on top regardless of z position.
By setting the material of the particles to the sprite material the z positioning is respected. Is there a better way to all particles to be render behind game objects? I didn’t see anything in the manual about this but might have read over it.
The material of the particles (and others) has a tag. This is what defines when it is rendered. Read the manual on rendering if you have not already. You could create a second material for particles, and then have one set of particles which you render below game objects, and another above, but you won’t be able to mix them. Or if you don’t care to have any above just move the position of the rendering of the particles to be before game objects.
If you don’t have a modified render script you’ll need to copy and paste the files from the built ins and then define the copies which you edit in the project.
In the custom render script, define the new tag predicate and also call render where you would like the new tag to show up. Earlier calls are drawn before later calls to render.draw. All the details are in the render manual:
I’m buuuuuumping this way back up to the top because i’ve just made a real working jet pack and it looks really great, but i’d like it to render behind my main character (and in front of everything else). Is there any way of getting this to work
TL,DR: How can I set the Z layer of particles in front of some game objects, and behind others?
Basically you need to create more render predicates. As is the Game Objects and ParticleFX are rendered on unique render predicates. Instead of co-mingling particles with GOs it would be better to have all ParticleFX on its own layer only, and then you can have multiple GO layers. Then order each layer of game objects / particles / game objects based on render predicates. Read up on the render documentation, modifying your render script, making new render predicates. If you have questions about it after reading ask here or your other thread.
Hmm… just noticed that tint doesn’t work with sprite material, though I don’t really need that.
Using “spine” material makes both z positioning and tint work, however.
In the end I just replaced the “particle” tag in the particle material with “tile” and that did the trick without messing around with the render script.
We can’t really think of a reason that particle fx is rendered in a separate pass. I guess it most often makes sense to interleave pfx with the rest of the graphics, and it seems like you have found a good way to do that. We may actually change this in the future so that pfx are interleaved, at least for new projects.