How do I make rule tiles connect with other rule tiles?

So I’m making a game similar to terria and I need my grass and stone tiles to connect. So how can I easily do this?

Terraria is a 2d voxel game. The answer pretty much lies in having a working, robust 2d voxel system suitable to your game, and using that alongside sprite maps for different materials to determine transitions between tiles.

If you don’t know about voxels then that’s priority number one as far as learning goes.

I’m not sure if I understand what you mean. I was asking on how can I make my rule tile connect with any other rule. Or act as if any other rule tile is the same. I should have probably made my post more clear on that

Well that sounds different to your initial question. What do you mean by a ‘rule’ tile, and what do you mean by ‘connect’? Because your initial question sounded like you wanted their sprites to transition, and if not, you need to be more clear and provide more context.

My apologies. By rule tiles I meant auto tiles or auto tilemap. I’m a bit confused on what there called and I thought they were called rule tiles in unity,.

Right this was probably a question better suited for the 2d forum as this isn’t exactly scripting related.

As mentioned Terraria is a voxel game with randomly generated levels, with the voxel system handled transitions between tiles… sort of. Some googling which found me posts from some Terraria’s artists/devs say that all the transitions were handled pretty much manually with massive tile maps for transitions between blocks of different types. Google ‘Terraria Tile Map’ and you’ll see.

So I don’t know the answer to your question specifically as I don’t do 2d and you asked this question in Scripting. Might want to report your thread to be moved.

The reason I put it in the scripting area is because you have to write a custom tile script for the tiles. Though I agree this would probably be a better forum post for the 2d section. I wasn’t aware of that section.

hi, i found a video about this,

, i’ve tried and for my project it worked, i suggest you try this too!

This video is a great find and I didn’t have any issues implementing the code and creating my custom tile script but I don’t really understand how to use what was made in the video? For example, how is the road rule tile he created able to switch between water and grass borders? Is it just designating one type of tile to a number (like water being set to 4) and then when creating the rule tile just setting all the water border road tiles to use the 4 in the rule tile? Sorry if this is worded strange but I can’t find any sort of documentation or video help with problems like these and am having the hardest time creating my world map

Hi there Primo!
Not sure if you’re still having this probem, but since I myself just started out, and got myself into the same kind of problem, this is how I fixed it:
Following the video above, here’s a MINIMAL matcher that simply mathes any existing tile from every tileset ever for the first rule, and only says that tiles are different when there is no tile at all.

[CreateAssetMenu(menuName = "2D/Tiles/EverythingMatcher")]
public class EverythingMatcher : RuleTile<TileGlue.Neighbor>
{
    public class Neighbor : RuleTile.TilingRule.Neighbor {
    }

    public override bool RuleMatch(int neighbor, TileBase tile) => neighbor switch
    {
        // Make old rule 1 match any tile from any ruleset
        Neighbor.This => tile != null,
        // Make old rule 2 only match when we have no tile at all
        Neighbor.NotThis => tile == null,
    };
}

Using this tileset, you can simply replace the RuleTile script with this new EverythingMatcher script (like he did in the video) and the default rules will (blindly, and all the time) match all other tilesets. If you want stuff to sometimes not match, I guess you’ll have to add rules of your own, but this is a minimum viable version to get everything to connect to everything.
Using my EverythingMatcher on three of my old RuleTiles, I was able to accomplish this:


which works for connecting two of my three tilesets because they use the same background color..
I’d say, start from there, then add new rules if you want to have more fine-grained control.
E.g, my minimal solution above can’t fix the problem betwen the green and the “alien” tileset, which clearly should have some sort of special transition or something.
To fix this new problem of mine, I would need something like a list of tiles that should not connect, or a third rule that only matches stuff in a separate list or whatever.
If you start from the minimal example above, you could extrapolate and modify it a little at a time until you get it right just the way you want it.