Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Gentle22 |
Dear Godot community,
I am working on a 2D project where I have a player sprite that should be able to be in front of a wall and walk behind the wall. I am using wall tiles with a width of 16 and a height of 48 pixels. My TileMap grid is 16x16. The TileMap has the Y-Sort option checked.
The player sprite has an y-offset to set the origin between his feet.
As you can see on the first image, as long as the player’s origin is above the wall tile’s top, it is drawn behind the wall. If I move it down, it is drawn in front which is wrong, since the player should still be behind the wall.
I fixed that by setting the tile’s texture offset to -48, like you can see on the next two images:
But I have the impression that this is the wrong way to do it, since I need to set the offset as well for collisions and occluders for each tile. Otherwise they are in the wrong place.
I would like to know if this is the correct way to do that, or is there a solution which works more out of the box.
Thanks and cheers.