Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

    coolblue2000

    Joined:
    May 7, 2015
    Posts:
    24
    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

    RidgeWare

    Joined:
    Apr 12, 2018
    Posts:
    67
    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

    coolblue2000

    Joined:
    May 7, 2015
    Posts:
    24

    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

    Antypodish

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

    coolblue2000

    Joined:
    May 7, 2015
    Posts:
    24

    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

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,584
    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

    coolblue2000

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

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