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

Question Painting two Rule Tiles at the same time. Where do I start?

Discussion in '2D' started by guiffen, Jun 23, 2021.

  1. guiffen

    guiffen

    Joined:
    Mar 17, 2013
    Posts:
    10
    I have a functioning Rule Tile currently, however I'm looking to prevent any art Rule Tiles from having Generated Physics on them. The generation is awful for non-standard art that doesn't fill a grid (like the grass in the example gif) and doesn't allow for creating no-collision on tiles with art in them when making custom physics changes in the Sprite Editor.

    So instead, I'm looking to create a duplicated/referenced Rule Tile that paints a custom collision map at the same time as painting the art. I have 6 other maps that have near identical art placements and so I can get a lot of reuse out of a collision map painter that follows a Rule Tile's rules at the same time.

    The Collision maps are painted identically as they're drawn over the art in the same PSD and exported as a separate PNG, however some squares in the Collision PNG are empty whereas the art PNGs in the same grid will have art. This seems to make the numbers for the individual map tiles (scriptable objects?) differ so I can't rely on just changing the name while matching the number.

    For these reasons, and also the

    TL;DR:
    I need a brush to both paint art and collision rule tiles based on their position on tilemap sprite's grid location but I'm really unsure what to search to even begin. I'm currently at a fork in the road with 20 forks and I can't seem to read the signposts.



    I'm a beginner to C# but understand very few basics like variables, types, creating a function, ifs.. but my biggest hurdle (I think) is not knowing what terminology to begin searching for this problem.

    On the forums I'm only finding information on how to code some things for tilesets but not Rule Tiles. I've only just learned how to make Rule Tiles too but I'm thoroughly confused how they even function or how they can be referred to as they don't seem to be a GameObject.

    I've downloaded 2D-extras for Rule Tile Overrides and thought the GameObject Brush might be the thing but it doesn't seem to help with this particular problem, or if it does, I'm just not seeing how.
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    While the Sprite Editor prevents you from creating a "no-collision" custom physics shape, you can set particular rules to produce no colliders and have other rules produce colliders if needed. This could simplify your workflow by having to only paint one Tile at a time.

    upload_2021-6-23_15-29-45.png

    You could try out the following brush to see if it suits your needs for this case (https://github.com/Unity-Technologi...brush/Editor/Brushes/LayerBrush/LayerBrush.cs).

    You would need to do a little setup for this.
    • Your Grid in the Scene would need to have two Tilemap GameObjects, one for the art Tiles and the other for the collider Tiles. Similarly, the Tile Palette would also need to have the same two Tilemap GameObjects, in the same order.
    • Using the default brush, you would paint the art Tile on the art Tilemap of the Tile Palette and paint the collider Tile on the collider Tilemap of the Tile Palette. The positions of the Tiles needs to be the same.
    • Once that is set up, you can switch to using the Layer Brush.
    • The Layer Brush will pick Tiles from the same position across all corresponding Tilemaps which are siblings of each other and paint Tiles to all corresponding Tilemaps in the target in the same position.
     
    guiffen likes this.
  3. guiffen

    guiffen

    Joined:
    Mar 17, 2013
    Posts:
    10
    That sounds like exactly what I'm looking for! Thanks a ton ChuanXin! I have to pass out here and try it tomorrow but may I ask how to load LayerBrush?

    It seems like it's part of the 2D-extras package and I have that loaded but there's no Layer Brush listed in the Tile Palette or in the Project menus. I'm looking under Create > 2D > Brushes , Tile

    It's also not in the bottom left pulldown menu of the Tile Palette either, or in the GameObject lists. Thanks again for your time!
     
  4. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Unfortunately, it is not part of the 2D-extras package. To use this, please download the Layer Brush script file and add it to your project.
     
    guiffen likes this.
  5. guiffen

    guiffen

    Joined:
    Mar 17, 2013
    Posts:
    10
    Ah, I'll watch for that in the future. Thanks again!