2D Toolkit Forum

2D Toolkit => Support => Topic started by: Bridgeman on August 22, 2014, 05:04:41 pm

Title: Player behind tiles in tilemap
Post by: Bridgeman 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.
Title: Re: Player behind tiles in tilemap
Post by: unikronsoftware 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.
Title: Re: Player behind tiles in tilemap
Post by: Bridgeman 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:

(http://i.imgur.com/O0v9BTa.png)

When I jump in another part of the level:

(http://i.imgur.com/0P4AeCD.png)

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?
Title: Re: Player behind tiles in tilemap
Post by: unikronsoftware 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.
Title: Re: Player behind tiles in tilemap
Post by: Bridgeman 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?
Title: Re: Player behind tiles in tilemap
Post by: unikronsoftware 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.
Title: Re: Player behind tiles in tilemap
Post by: Bridgeman 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?
Title: Re: Player behind tiles in tilemap
Post by: unikronsoftware on August 23, 2014, 07:32:04 pm
Tile map layers, in the tile map editor.
Title: Re: Player behind tiles in tilemap
Post by: Bridgeman 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?
Title: Re: Player behind tiles in tilemap
Post by: unikronsoftware on August 23, 2014, 11:56:16 pm
What exactly are you trying to do here? Some pics would really help.
Title: Re: Player behind tiles in tilemap
Post by: Bridgeman 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?

(http://i.imgur.com/bLASPm1.png)
Title: Re: Player behind tiles in tilemap
Post by: unikronsoftware 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.
Title: Re: Player behind tiles in tilemap
Post by: Bridgeman 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.