# How do I make custom tiles on one tilemap aware of those on another?

Discussion in '2D' started by coolblue2000, May 24, 2019.

1. ### coolblue2000

Joined:
May 7, 2015
Posts:
23
I have two tilemaps. One is the walls and the other the floor.

I have custom tiles for the wall so that they automatically create corners etc as I paint

I want my custom wall tiles to align with the floor (ie place a left wall when painted to the left of the floor etc) but as they are on separate tilemaps they are not aware of each other. How do I do this?

JulsYa likes this.
2. ### RidgeWare

Joined:
Apr 12, 2018
Posts:
65
Are you using Rule Tiles correctly? All the rule tile needs is to know whether there's a red arrow on that particular adjacent tile (meaning there is no tile there) and it will apply the correct tile asset for that position.

I've been able to build left/right walls on a separate tilemap to the floor with no problem. There are some rule tile tutorials on Youtube.

3. ### coolblue2000

Joined:
May 7, 2015
Posts:
23

But isn't the ITilemap property on GetTileData() the tilemap that the current tile is on? I am using custom tiles not rule tiles.

Last edited: May 24, 2019
4. ### Antypodish

Joined:
Apr 29, 2014
Posts:
6,840
Use 1D array, to represent whole 2D tail map. Then you can find neighbors with ease, using index offset.

5. ### coolblue2000

Joined:
May 7, 2015
Posts:
23

How do I get hold of the tile maps to put them in the array? I only appear to have access to the current tiles tilemap

6. ### Antypodish

Joined:
Apr 29, 2014
Posts:
6,840
You know xy position, you can calculate index offset and vice versa. That is, providing you know size of map.

So for example 100x100 if you want get index, you calculate = y * 100 + x
You array can be other book, int or class, which contains data of tail. In such class, you can define, if os occupied, type of tail, orientation and other properties if you like.

7. ### coolblue2000

Joined:
May 7, 2015
Posts:
23
I think we might be talking about different things.

I am using the built in Unity Tile Map and using Custom Tiles with it.

unityunity