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

How To Check The Neighbourhoodiness Of A Tile

Discussion in '2D' started by aybarsmete1, Nov 28, 2019.

  1. aybarsmete1

    aybarsmete1

    Joined:
    Oct 26, 2019
    Posts:
    43
    So, we all know rule tiles. However the thing I want to do is, instead of the same type of tile, whatever tile is neighbour with that tile, it would change.
    Let me give you an example:
    If there is a block under this tile, it's sprite look like this:(Whatever tile is it)
    pixil-frame-0 (22).png
    And if there is not any tile under it, it should look like this:
    pixil-frame-0 (21).png
    You get the idea.
     
  2. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @aybarsmete1

    You can achieve this with scriptable tiles. Just check if there is tile below and not above and draw sprite 1 and so on.
     
    MisterSkitz likes this.
  4. aybarsmete1

    aybarsmete1

    Joined:
    Oct 26, 2019
    Posts:
    43
    I don't know the code..
     
  5. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi again @aybarsmete1

    I'll say this - did you actually bother to google for this?

    As Unity has given one example in manual, and more in 2d-techdemos - no need to start inventing it yourself!

    I find Tilemap pretty convoluted to use from code... and IMHO these examples are really helpful. If you read the tilemap code examples, you will also see how they did the directional "does tile exist in direction x" kind of checks too. You don't have to read rule tile's code, which contains pretty much everything from other (scriptable tile) examples.
     
    Last edited: Nov 29, 2019