Please help a beginner link terrains together.

Godot Version

4.3 Stable

Question

Hello!
I am very new to Godot and am experimenting. I am trying to create a random ‘dungeon’ with different rooms. Each room has a theme and a terrain to match it.

I am creating the rooms randomly in code and using: set_cells_terrain_connect(cells,0,Tiles.get(room.type))
to autotile each room with at least a 1 tile gap between each room.

So far, this works well.

However, I am trying to link the rooms with a corridor. The corridor has its own terrain. When I place the corridors, it draws them in the correct place, but the autotile doesn’t choose a tile that looks like they are connected. In other words, the corridor terrain doesn’t see the rooms at either end of it.

All the terrains are part of the same set: Terrain Set 0.

I am sure I read that we should be able to link different terrains as long as they are in the same set, but I cannot figure out how.

I tried making all the terrains the same index, but that meant I couldn’t differentiate them and they were jumbled up.

I tried having the center bit different for each terrain, but the peering bits the same between terrains, but then it wouldn’t even match with anything, even itself.

I tried creating alternate tiles for every combination of corridor/room but that wouldn’t detect the rooms either.

Clearly I have misunderstood something, but I cannot work out what.

Please help!

Edit to add a picture:
Left is what I want to happen, right is what is happening.
problem

To automatically connect cells with code you have to place them all at once with this call set_cells_terrain_connect(cells,0,Tiles.get(room.type)), i think otherwise it will not check for connections

1 Like

That makes sense, but they are different terrains albeit in the same terrain set.
I attempted to make them the same terrain at one point, but I couldn’t differentiate between the textures so I couldn’t “theme” the rooms.

Do you happen to know a way to do that?

No i dont know how to do that. Maybe have a look at tilemap patterns

Well, I have found a solution to the problem, but I don’t know whether it’s the only or even the best solution.

I have used the “better-terrain” plugin by PortPonky.

As a beginner, I’d originally steered away from using plugins as I wanted to learn the core stuff first, but I’m glad I didn’t stick to that.
Very easy to set up and use.

I’m sure everyone here already knows about/uses it, but for any beginners like me, it’s worth checking out here:
Better Terrain on GitHub
It’s also available in the AssetLib.

1 Like