0 votes

My first attempt to implement objects involved a tilemap, adding single-tile objects. The primary issue I have encountered relates to how those objects are y-sorted with the player:
Background: I have a player whose collision box occupies one tile, but whose sprite is larger than that single tile. I also have a tree sprite which occupies a 2 wide by 3 high tile area and has a two tile wide collision box at its base. The player should be able to move behind the tree and appear behind it, and appear in front when in front of it.
The issue: When the player is standing below the top row of tiles of the tree object (which I have presently created and added to the game using a tilemap, single tile object), it is displayed in front of the tree when it should be behind it.

The player in the middle two tiles of the tree: https://imgur.com/a/1iSjnTN

When the player is in the top two tiles of the tree or in front of the tree, it displays correctly. At present, I believe that this is caused by the tilemap's default selection of the top left tile of a single tile object as its origin tile, while in this case it would make more sense for it to be the bottom left tile.
I am not sure precisely how to resolve this or if there are other approaches that could be equally effective.
I have tried using a YSort node and swapping the hierarchy of my player/tilemap nodes without success. Changing the tilemap tile origin does not work, as it seems to only refer to the origin tile and not the object as a whole.

in Engine by (12 points)

What I did for something similar was to split the tree into two parts, top and bottom, and place them in two different tilemaps, one of which was above the player node in the hierarchy, and one of which was below the player character in the hierarchy to control the draw order.

That sounds like it would work reasonably well, but it would make actually placing the objects a bit more time consuming, especially if I am going to place a ton of trees or something. Kind of strange that it's not intuitively possible to get multi-tile objects working within a single tilemap.

I only made trees that the player would get near two parts. Trees out of bounds would just be one part.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.