'Unity Tilemap layer order sorting [Player in front of and behind tiles] Tree sprite consisting of 4 loose tiles

I've been slowly working myself into Unity2D as i'm branching off from web development. As a result I'm currently stumbling against a rendering issue I've had where in a tilemap i have trees (and multiple other objects in the future with the same style) where one tree is made up of 2x2 tiles. The player needs to walk in front of and behind the tree based off of it's Y value. This works, only is the player counting the tree as 4 separate sprites so it displays the player behind one sprite at a time.

My question is, what would the solution be to properly render the player in front of the tree and behind. The solution needs to be dynamic as to where i can for example, make a player 3 tiles high and still work as intended.

Unfortunately i cannot place images on SO just yet as I've just made this account.

  • I have messed around already with the Project graphics settings to where I've changed the transparency sort mode and axis, the axis would be at 0/1/-1 now.
  • I've placed the player's layer and the tilemap's on the same layers.
  • The Tilemap renderer's mode is individual, according to online guides and possible solutions.

I hope the solution will bring me to a way where i can dynamically add anything like a crate, a barrel of 2 tiles high and anything in that sense where i just have to place them, i wouldn't have a problem if it'd be possible to create one tile which would be 2 tile spaces big.



Solution 1:[1]

This link might help you out: https://gamedev.stackexchange.com/questions/119734/unity-order-in-z-layer-for-objects

In this proposed solution however, the tree can't be part of the tilemap.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vTB57 v