#Setting transitions between tiles progammatticaly

1 messages · Page 1 of 1 (latest)

restive tree
#

Hi, I have a Terrain Generator that uses Perlin Noise, what are some ways I can make it have tile boundaries between biomes, as I have tiles that are for when two biomes meet, such as waterto grass, or stone to grass. Here is my current implementation that does not work. I believe its failing to set due to the transition value.

void ApplyTransitionTiles()
    {
        BoundsInt bounds = tilemap.cellBounds;

        for (int x = bounds.x; x < bounds.x + bounds.size.x; x++)
        {
            for (int y = bounds.y; y < bounds.y + bounds.size.y; y++)
            {
                TileBase tile = tilemap.GetTile(new Vector3Int(x, y, 0));

                if (tile != null)
                {
                    string currentBiome = GetBiomeFromTile(tile);

                    // Check adjacent tiles and apply transition tile if needed
                    for (int i = -1; i <= 1; i++)
                    {
                        for (int j = -1; j <= 1; j++)
                        {
                            if (i == 0 && j == 0)
                                continue;

                            Vector3Int adjacentPos = new Vector3Int(x + i, y + j, 0);
                            TileBase adjacentTile = tilemap.GetTile(adjacentPos);

                            if (adjacentTile != null)
                            {
                                string adjacentBiome = GetBiomeFromTile(adjacentTile);

                                if (currentBiome != adjacentBiome)
                                {
                                    float transitionValue = CalculateTransitionValue(x, y, i, j);
                                    if (transitionValue > transitionThreshold)
                                        tilemap.SetTile(adjacentPos, transitionTile);
                                }
                            }
                        }
                    }
                }
            }
        }
    }```
#

Setting transitions between tiles progammatticaly

slim pawn
#

Hi!

#

So, how do you decide each biome?

#

I'm on phone and that code doesn't format correctly

#

I'm gonna throw an option, if you are setting a biome like 0 to. 3 of perlin, rock.3 to. 6 grass and. 6 to 1 water

#

You can change rhat to add an in-between fake biome that acts as transition

tardy pumice
#

Not seeing much here to go off of, but check all neighbors and if it's another biome then you resolve how you want it. I'm not seeing the problem.