How to fix terrain Z axis going up on the end and on the X axis its going down?

Viewed 38

so I'm rewriting my old code for a hydraulic erosion terrain generator, I knew about this problem on my old code but never asked why, but now I'm rewriting it and want to get everything working smoothly

this is the issue on my Z-axis at the edges the terrain has a step up and on the X-axis it goes down but it's hard to see in the photo plz tell me why

I'm using the built-in terrain generator FYI if you need more code just tell me

enter image description here

enter image description here

public void GenerateHeightMap () {
    mapSizeWithBorder = mapSize + erosionBrushRadius * 2;
    map = FindObjectOfType<HeightMapGenerator> ().GenerateHeightMap (mapSizeWithBorder);
    terrain.terrainData = GenerateTerrain(terrain.terrainData);
}


TerrainData GenerateTerrain(TerrainData terrainData) {
    Erode();
    float[,] noiseMap = new float[mapSizeWithBorder,mapSizeWithBorder]; 

    int x = 0; 
    int y = 0; 

    for (int i = 0; i < map.Length; ++i)
    {
        noiseMap[x, y] = map[i];
        y++;
        if (y == mapSizeWithBorder)
        {
             y = 0;
             x++;
        }
    }

    terrainData.size = new Vector3(mapSizeWithBorder * scale, elevationScale, mapSizeWithBorder * scale);
    terrainData.SetHeights(0, 0, (noiseMap));
    return terrainData;
}
0 Answers
Related