For a project I'm working on, I want to set the Z Index relative to an objects Y position on screen. As an example, Object A is at (52,127), I want to essentially have an action run every tick to set this objects Z Index to 127. The effect I'd like to achieve with this is so that when say Object B is overlapping Object A but at a lower Y value, I want it to appear to be "further back" than Object A. In other words, I'm trying to achieve an illusion of Depth. Right now as a temporary workaround, I have a few of my objects set their Z Index relative to each other object with a command running every tick to compare two objects Y Values. This of course is very tedious and rather time consuming, and in fact a bit messy as I have a number of different objects that need to have their Z Index update constantly and I think it would just be easier to set their Z Index relative to their position on screen.
It's probably worth noting that I'm a bit of a scrub when it comes to this kind of stuff so if there's a much easier way to do this, please let me know, otherwise any assistance is greatly appreciated.