Smoothly deform terrain

Hi, I created a dig method for my terrain, which is supposed to decrease each point on the terrain within a certain radius x amount of units. It works, but when the hole becomes steep, random vertices begin popping up, probably in an effort to smooth out the terrain. How can I stop this? Here is my method :

    Vector3 tPos = transform.position;
    TerrainData tData = GetComponent<Terrain>().terrainData;

    Vector2 digPoint = new Vector2();
    digPoint.x = ((point.x - tPos.x) / tData.size.x) * tData.heightmapWidth;
    digPoint.y = ((point.z - tPos.z) / tData.size.z) * tData.heightmapHeight;
    float[,] heights = new float[radius, radius];
    for (int i = 0; i < radius; i++)
    {
        for (int j = 0; j < radius; j++)
        {
            int x = (int)digPoint.x + i;
            int y = (int)digPoint.y + j;

            float newHeight = Mathf.Max(tData.GetHeight(x, y) / tData.size.y - depth * Time.deltaTime, 0f);
            heights[i, j] = newHeight;
         }
    }
    tData.SetHeights((int)digPoint.x, (int)digPoint.y, heights);

Any help is appreciated!

I found this method which essentially ignores the LOD update :slight_smile: