Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rule Tile, if multiple tiles share the same rules question.

Discussion in '2D' started by Azure123, Sep 29, 2022.

  1. Azure123

    Azure123

    Joined:
    Feb 20, 2017
    Posts:
    8
    Hi!

    Regarding Rule Tiles, if multiple tiles need to share the same rules, is it possible to adjust which one is selected in specific locations?

    Example in the images below:

    1.png 2.png 3.png
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Generally you want to list more complex rules higher up than less complex rules.

    Your second-listed rule should be first. Also, it should have an arrow to the up-right from the center. d.png
    Edit: now that I think about it a bit more, you might need to turn on Extend Neighbor and add an [X] directly above that newly-added green arrow.

    Rules are a bit hard to create/fix in the imagination so I hope that's right. Give it a try.
     
    Last edited: Sep 29, 2022
  3. Azure123

    Azure123

    Joined:
    Feb 20, 2017
    Posts:
    8
    Thank you.

    While I did manage to somewhat solve the problem in the example, the issue remains in other areas of the rule tile which is not as easily solved, so the question remains.

    Maybe I wasn't super clear in the original question, is there a way to overwrite the rule of a specific placed tile outside of a simple reorder or a custom tile script without breaking it's neighbors? Kind of like the Rule Override Tile but you can target where it applies.
    4.png
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Sorry for delay. If I understand correctly, I've done something similar by customizing/overriding the RuleTile script and adding an array of TileBase[] friendTiles. Neighboring tiles are normally evaluated by whether they are (a) this or (b) not this. These friendTiles get counted as this, so as a result they don't appear to break the RuleTile when adjacent to one. However, I haven't used the newest versions of Tilemap Extras so maybe there's a more modern way of accomplishing the same. Hope that helps.
     
  5. Azure123

    Azure123

    Joined:
    Feb 20, 2017
    Posts:
    8
    Thank you for taking the time trying to help!

    Ended up finding suitable solution in the below code:
    https://github.com/Unity-Technologi.../Rule Override Tile/ExampleSiblingRuleTile.cs