3
\$\begingroup\$

I am trying to use Y-Sorting on a tilemap tree to Y-Sort the whole tree, but it is Y-Sorting each tile of the tree instead of the tree as a whole:

player character being sorted behind some tree tiles and in front of others

I have tried adjusting the Y-Sort Origin but that didn't work. I am trying to make the tree render completely over the Character when he's behind and below when he's in front.

\$\endgroup\$
4
  • \$\begingroup\$ Do you have Y-Sorting enabled for both the TileMap itself and the tilemap layer that holds the tree? Do the TileMap, the tilemap layer with the tree and the character all have the same Z index? \$\endgroup\$ Commented Aug 31, 2023 at 15:54
  • \$\begingroup\$ Also, you need to leave a blank line between your question post body & the image lookup info (i.e. before the line [1]: https://i.sstatic.net/abcdef.png or whatever) for the image to render correctly in your post. If you remove it, renders as a unresolved markdown text & link instead. Refer to the edit link under your post to see what I mean. \$\endgroup\$ Commented Aug 31, 2023 at 15:59
  • \$\begingroup\$ @Pikalek thank you for that advice. Also Yes I got both Y-Sorting enable and they are on the same Z Index. I just realized I didn't word this question good and will edit it. The tiles are sorting correctly, but I want the whole entire tree to Y-Sort at the same time instead of each indivisual tile of it. \$\endgroup\$ Commented Aug 31, 2023 at 16:05
  • \$\begingroup\$ Yes, that info changes things & you should definitely edit to reflect that (comments don't always get read so other might not notice you've mentioned the info down here). Offhand I'm not sure there's a simple way to have a group of tiles sort as a composite unit. I've seen some folks use special tiles to dynamically spawn in other scenes - it might be possible to use such a tile to mark the base of the tree & add the rest separately, but it's not a technique I've tried myself yet nor am I sure how well suited it is to your situation. \$\endgroup\$ Commented Aug 31, 2023 at 18:52

2 Answers 2

3
\$\begingroup\$

If I have correctly recreated your situation.

shows a character that is located in inside a tile group

Solving:

You change the atlas so that it is a single tile, for example 2 by 3.

atlas parameters are shown

Result:

a character is shown standing behind an obstacle

The above solution is the most correct. But I also have an alternative below.


Alternative (not the best method)

You select coloring in the tile set and specify the Z-index in the properties.

\$\endgroup\$
2
  • \$\begingroup\$ I' have the same problem but none of the two option are a good solution. I want to build different houses from single tiles with different width and heights. I also want to go behind the house. So I cant merge or use the Z-index. What is option 3? :-) \$\endgroup\$ Commented Oct 17, 2024 at 19:40
  • \$\begingroup\$ @meleagros Why can't you use the Z-index or merge? --- First, you can write a shader that makes blocks transparent in front of the character so that you can always see it. --- Secondly, when entering a house, you make the roof invisible. To do this, you can combine elements into a group and apply a signal to this group when the character passes through the door, for example --- Third, use a SubViewport, a room inside the house and a house in separate scenes and just overlay the SubViewport image on top of the house. At the same time, you teleport the character to SubViewport \$\endgroup\$ Commented Nov 23, 2024 at 21:09
1
\$\begingroup\$

You should be able to adjust the Y-Sort Origin of the top tiles to be at the same y position as the bottom tiles. That way all four tiles will get y sorted the same and behave the same relative to the player.

So if your tiles are 64px tall, then set Y-Sort Origin for the top to be -32 and the bottom two to be 0.

(You mentioned adjusting the Y-Sort Origin, but it's not clear what didn't work. Hopefully this is helpful.)

\$\endgroup\$
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.