ZOrder dilema with Paper2D

Paper2D uses Y for depth but still uses Z for the ZOrder.

This is creating problems with sorting objects. Is there a solution to this?

Issue on 4.7.2, haven’t had a chance to test on 4.7.3 yet.

Shameless one-time bump. Is there a setting I have to change or something of that sort?

There doesn’t appear to be a Set Actor Sort Order node in blueprints either to manually do it.

To explain my problem better:

I have a bush on the following axis: Z = 100, Y = 0

and a tree on: Z = 50, Y = 50

In the viewport the tree is behind the bush, as it should be. But at runtime it sits in front of the bush because the Z axis is closer to 0.

Since Paper2D sorts depth on the Y axis this shouldn’t be happening.

Are your sprites translucent or masked/opaque? What do you have the rendering ‘Sort Translucent Policy’ project setting set to (most of the time for 2D games you want to set it to ‘Sort Along Axis’)?

Masked/Opaque sprites ignore Sort Key and the Translucent Sort Policy, the only thing that matters for them is ‘z’ ordering compared to the camera (distance to camera for each individual fragment, in whatever axis you’ve got the camera pointing; for most Paper2D uses ‘z’ is Y). For translucent objects, the sort key wins out over everything (set on the advanced settings of the component), and after that the sort policy determines ordering. The default (best for 3D) policy is ‘sort by distance’ which sorts based on distance from camera center to object center, but for 2D you usually want to use the projected distance along the axis, as that avoids issues with small objects in front of larger objects sorting behind them because they were off to the side (longer diagonal line).

Cheers,
Michael Noland

I’ll check into those as soon as I am at my computer. I couldn’t find any such settings while browsing around my project. Also, web search results weren’t very helpful either.

Also, I would assume my sprites are opaque as I have not changed any default settings. There’s no transparency on them.

Before 4.7, the default is masked, and as of 4.7 it analyzes your texture and picks either masked or translucent based on the presence/absence of smooth alpha data in the texture. It never picks opaque automatically to avoid ‘broken expectations’ if you go edit the texture later on.

The materials for the automatic choices are defined in the Paper2D project settings, so you could change them to something different than the default unlit materials provided in the plugin, which will take effect for any new sprites you create.

Cheers,
Michael Noland

Everything is working now after setting Translucency to “Sort Along Axis” as you mentioned. I saw that feature early but the number values made it unclear to me so I passed over it not thinking it was related.

Thank you for the explanations as well. Added it to my giant list of tips.

Hello. I have similar problem, but when i use TranslucentLit material, light is bad:
I use TranslucentLit material to a TileMap with tile offset correctly draws (tiles with other materials begin to flicker). But when using a point light - square discarded


How to make a normal light with TranslucentLit material?
Please help me :slight_smile: