For the main scene, I have:
world (y-sorted enabled, z index as 1, z as relative enable)
------ground (tilemap layer) (y-sorted disabled, z index as 0, z as relative enabled)
------fences (tilemap layer) (y-sorted enabled, z index as 1, z as relative enabled)
------player (characterbody2d) (y-sorted enabled, z index as 1, z as relative enabled)
For the player scene, I have:
Player (y-sorted enabled, z index as 1, z as relative enabled)
------animatedsprite2d (y-sorted enabled, z index as 1, z as relative enabled)
------collisionshape2d (y-sorted enabled, z index as 1, z as relative enabled)
I want the player and fences to have y-sorted functioning
I watched a few tutorials online and searched some discussions here, but still no solution for me.
What are you seeing? Is the player always in front or behind? Was there any effect of enabling y-sort? Did you paint the tilemap fence on the right layer? Oh yea, keep the collision shape at z-index 0, i think it will become 1+1 = 2 if the characterBody2D is 1 aswell.
the player is always in front of the fences.
I disabled the y-sort of all except world (including all in the player scene), the player is now always behind the fences.
What do you mean by the right layer? Is there a place for managing the layer of the tilemap?
There are layers within the tilemap for giving different tiles different properties, i made a short video to illustrate:
Y-sort should be enabled for the tilemap-node and for the layer containing the fence. It should also be on for the characterBody2D of the player. I did alot of fiddeling around with this myself, dont lost heart!
Thanks for your help.
Turns out I did not change the center point of the player’s animation to the same position as the collision2d ones, so the y-sort is actually functioning but I didn’t change the player’s y-origin(or smth like that).
And now it’s working fine!