0
\$\begingroup\$

This is my first time using Unity (and my third time creating a game in general), so I hope I can provide the needed information to solve this problem. Lower Wall Interaction Upper Wall Interaction My character overlaps with the upper wall, but doesnt with the lower wall. This is the right behaviour given the layers (seen in the picture). But I want him to be behind the lower wall AND in front of the upper wall.

Side Information:
- The Wall Tile is one piece, which covers two tiles.
- Movement is depended on the existents of a ground tile. The reason behind this is, that I wanted the character to always move one tile at a time. And since this is my first time with unity, that was the easiest way of doing it. So there is no actual interaction with the wall. No collsions or anything.
- There are three Layers (Ground, Creature, Wall) and two tilemap layers (Ground and Wall) (see picture) and the character doesnt interact with the tilemaps at all, he just gets drawn above the ground tilemap layer.

What I see as answers:
- Split the wall tile into two tiles and let the wall part be on another layer, then the roof part.
- Split the character into two parts and do the same thing.
Both seem like a good way of solving it, but I dont even know where do start there. I think I can split the walls into two tiles, but I dont know if this is a good way to solve this issue. The other option, to split my character, there I really dont know where to start.

What I tried:
- Trying around with layers and order in layers.
- Trying around with the tile atlas (adding the sprite, removing tiles)

\$\endgroup\$
  • 1
    \$\begingroup\$ "I think the problem is pretty obvious" remember that search engines don't parse meaning from images or inferences (yet?). So if you want people to be able to find your question, be sure to describe your problem in text, even if you think it's obvious. This will both help you attract more answers, and make it easier for folks experiencing similar issues to find your post and learn from your case. \$\endgroup\$ – DMGregory Sep 26 at 11:37
  • \$\begingroup\$ This Unity forum post seems to suggest you can make your character sort together with your tilemap layers automatically. Have you tried implementing the advice described there? \$\endgroup\$ – DMGregory Sep 26 at 12:48
  • \$\begingroup\$ Thanks that was the answer, should I post the answer or you? \$\endgroup\$ – Christopher Sep 26 at 13:21
  • \$\begingroup\$ I recommend posting your own answer, with screenshots of how you solved the problem. I won't be able to do the same since I don't have your project. ;) \$\endgroup\$ – DMGregory Sep 26 at 13:30
1
\$\begingroup\$

You essentially have 3 options:

1.: Since your walls are 2 tiles high, you can simply set the top tile to render in front of the player and the bottom tile to render behind the player. If the player is less than 2 tiles tall, then this will work pretty well.

2.: Create 2 layers for the wall, one of them should render behind the player, the other in front. Then you can dynamically move the tiles from one layer to the other based on their relative y position from the player.

3.: Instead of using 2d tiles for the wall, make them 3d. A lot of games do this, e.g. Enter the gungeon:

enter image description here

This has the added benefit, that it makes lighting a lot easier

\$\endgroup\$
  • \$\begingroup\$ Thanks, the third options doesnt go for me. This is a project for my study and I only have 1,5 month left. Now changing to 3D, isnt something I want to look into. But still cool to know for when I start my own project in my own time. The second option I though about myself, because I have read about "Scriptable Tiles". Then I could let the tile itself place the roof part of the wall. The first options sounds the easiest, but I dont know how I would do this. Can you explain a little further? How can I set this top tile to render in front and the bottom tile to render behind? \$\endgroup\$ – Christopher Sep 26 at 12:24
  • \$\begingroup\$ @Christopher divide the two tiles and place them on separate layers. If the bottom tile stops the player, then he won't be able to go below the top tile. \$\endgroup\$ – Bálint Sep 26 at 13:20
0
\$\begingroup\$

After following the help on this side https://forum.unity.com/threads/isometric-tilemap-sorting-issues.554914/#post-3692299 (thanks again DMGregory).
I changed the following things: Camera Settings First of all the camera settings to Custom Axis and changed the Sort Axis. (try to change the Z Value, because many other had different values there.) After that I changed every layer to the same layer "Default" and put my player and walls on Order "1" (the ground on "0".) Then the Cell Size of your grid needs to have a Z Value of at least 1. Last Thing is that you need to change the sprit Pivot to custom and the sprite sort point to "pivot" for your player character.

After that it works fine.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.