I’ve spent the day generating worlds using terrain, custom meshes and cubes. I want to achieve a look similar to Kingdoms and castles (Kingdoms and Castles on Steam)
using terrain or custom mesh with perlin noise did not really work since I could not get the 90 degree angles I need to achieve the look. I ended up getting the map generator that uses cubes to work, code looks like this:
public void GenerateMap()
{
DestroyTiles();
float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, noiseScale);
for (int x = 0; x < mapWidth; x++)
{
for (int y = 0; y < mapHeight; y++)
{
int posX = x * 10;
int posY = y * 10;
Tile tile = new Tile(posX, posY);
if (noiseMap[x, y] >= waterAmount)
tile.gameObject = Instantiate(grassTile, new Vector3(posX, 0, posY), Quaternion.identity);
else
tile.gameObject = Instantiate(waterTile, new Vector3(posX, 0, posY), Quaternion.identity);
tiles.Add(tile);
}
}
}
Basically I can choose a scale and wateramount, and end up with a map like this:
I quite like the look, however, if I go over a size of 50x50 (each tile is 10 meter squared), Unity gets quite slow. So obviously this is not a scalable or performant approach.
Can anybody either show me an approach that gets a similiar effect to this using a single mesh, or advice me on how I can make my current setup more performant?
