Hello Guest

Author Topic: Player behind tiles in tilemap  (Read 12356 times)

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Player behind tiles in tilemap
« on: August 22, 2014, 05:04:41 pm »
Hello,

I've created a level using a tilemap and added in a placeholder player. However, for some tiles, the player overlaps them, and for other tiles they overlap the player. But all my tiles are on the same layer in the Tilemap. So how do I get control over this? I want to decide which tiles should overlap and which shouldn't.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Player behind tiles in tilemap
« Reply #1 on: August 22, 2014, 07:42:06 pm »
You can use sorting order on the player sprite to control this. Note - you can't have some tiles overlap the player and others not.

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Player behind tiles in tilemap
« Reply #2 on: August 22, 2014, 11:37:14 pm »
You can use sorting order on the player sprite to control this. Note - you can't have some tiles overlap the player and others not.

Well, that's exactly my problem. I really don't know what's going on, but I figure it's easier if I show some pictures:

When I jump in one part of the level:



When I jump in another part of the level:



Now I don't really like either of them, but if I had to choose I'd prefer it to be like in the top image everywhere. Is there a way to fix that?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Player behind tiles in tilemap
« Reply #3 on: August 23, 2014, 10:44:48 am »
Exactly what I said in the previous post - use the sorting order on the player sprites to make it draw in front of the tilemaps. Tilemaps have a value of 0, so anything larger will draw on top.

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Player behind tiles in tilemap
« Reply #4 on: August 23, 2014, 07:06:32 pm »
But then what if I wanted to make an RPG? There would be a lot of objects that would need to overlap the player. Can't that be done in one tilemap?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Player behind tiles in tilemap
« Reply #5 on: August 23, 2014, 07:20:45 pm »
You can mix tilemap layers and sorting order to get what you want. With certain other game types you'll have to use other means of sorting, especially if tiles overlap. Most should be fine with multiple tilemap layers and sorting the player appropriately.

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Player behind tiles in tilemap
« Reply #6 on: August 23, 2014, 07:29:08 pm »
You can mix tilemap layers and sorting order to get what you want. With certain other game types you'll have to use other means of sorting, especially if tiles overlap. Most should be fine with multiple tilemap layers and sorting the player appropriately.

You mean the layer drop down menu in the top right of the player object right?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Player behind tiles in tilemap
« Reply #7 on: August 23, 2014, 07:32:04 pm »
Tile map layers, in the tile map editor.

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Player behind tiles in tilemap
« Reply #8 on: August 23, 2014, 08:45:21 pm »
Tile map layers, in the tile map editor.

There's an option for Unity Layers as well as Sorting Layers. Do I need to change the Unity Layers as well, or can I leave those alone?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Player behind tiles in tilemap
« Reply #9 on: August 23, 2014, 11:56:16 pm »
What exactly are you trying to do here? Some pics would really help.

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Player behind tiles in tilemap
« Reply #10 on: August 24, 2014, 09:01:58 pm »
What exactly are you trying to do here? Some pics would really help.

Here in the Tilemap settings there's an option for Sorting Layers as well as Unity Layers. If I want a certain layer to overlap the player, do I need to change both of them or just the Sorting Layers?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Player behind tiles in tilemap
« Reply #11 on: August 24, 2014, 09:52:33 pm »
Sorting order in layer should be sufficient. Give them ascending values, in the order you want them to draw.

Bridgeman

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Player behind tiles in tilemap
« Reply #12 on: August 24, 2014, 11:12:09 pm »
Cool, I finally got it working now. The whole Unity Layers thing thrown into the mix just confused me at first. Thanks for clearing this up.