Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Pennycook |
I’m trying to use YSort with a player and some objects created from tiles in a tilemap.
The objects are constructed from individual tiles deliberately, and I’d like to keep this set up if possible.
I’ve uploaded a simple example project here. The arrow keys move the player.
I have a wardrobe that is 3 tiles high. It doesn’t completely occupy 3 tiles, and is slightly set back within the bottom tile to make it appear as though it is pressed against a wall. I’ve drawn a blue line at the bottom of the tile to show where it is. The player is of a similar height, and I’ve drawn a red line to represent the player’s feet.
The origin of the player is at its feet, and the tilemap is set to have its origin in the bottom left.
YSort compares the bottom of the tile (i.e. the blue line) against the bottom of the player (i.e. the red line), leading to situations like this:
What I want is to set the Y coordinate that the tile uses for YSort to the bottom of the wardrobe, but I can’t work out how to do it. Is it possible?
I’ve seen lots of people talking about using the Tex Offset property to fix situations like these, but I don’t understand how that would apply in this case. Changing the Tex Offset moves the wardrobe sprites down (and away from the wall), and defeats the point of offsetting them within the tileset image in the first place.
Just wondering, why do you want to have the origin on the bottom left?
exuin | 2020-10-02 04:19
Based on tutorials and other posts I’ve read about YSort, it seems to be the easiest way to reason about things. The player’s location is represented by the character’s feet, so it’s logical that the position of other objects is represent by the lowest point as well. Of the three origin options that TileMap provides, “Bottom Left” is the closest.
I was hoping I could offset the origin to fine-tune the behavior of specific tiles, but maybe it’s not possible.
Pennycook | 2020-10-02 05:02
It’s just that if you set the player as a child of the tilemap node and set the y-sort of the tilemap node to top left, it works, since the player character’s feet is lower than the top left of the tiles.
exuin | 2020-10-02 05:09