Sorry for replying late. I'm afraid to say these methods didn't really work :/
The tutorial example doesn't work, because I don't want the player to be displayed at all when passing behind objects.
The method by Destitute doesn't work, because the actions, once again apply for all instances of an objects and this creates glitches, when the player passes around multiple layers of objects. For example: if the player is slightly behind one object, but also slightly in front of another object, the player object will be displayed behind both objects.
Does anyone have any other solutions?
Thanks.
I forgot to note, but my method doesn't work for you because all objects need to be on one same layer with the screenshot I posted, including the player.
I used to have multiple layers (one for the player/enemies), objects above Link (such as the bridge overpasses inside of Hyrule Castle), below Link (switches) but I switched to one layer and started using family y ordering since in my opinion, having too many layers can cause unexpected (nature of bugs, half of the time, you don't expect them...) emergent problems later on and having most if not all objects on one layer makes them easier to debug, as long as the y ordering is initially done correctly.