Can you update my terrain generator script below i am wanting to change it from using rectangular boxes to a smooth terrain as seen in the image below i am using unity 2d

https://i.gyazo.com/cbe064de3f53d36fdfac422463ed143d.png

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TerrainGenerator : MonoBehaviour
{
    public int tileCount = 50;
    public float noiseScale = 1.0f;
    public float heightRandomness = 1.0f;
    public Color terrainColor = Color.magenta;
    public Color bottomLayerColor = Color.gray;

    public int depth = 5;
    public float maxHeight = 20;
    public float bottomLayerHeight = 1;
    int minHealth = 50;
    int maxHealth = 150;

    private List<GameObject> terrainTiles = new List<GameObject>();

    void Start()
    {
        GenerateTerrain();

        // Find the player with the tag "Player"
        GameObject player = GameObject.FindWithTag("Player");

        if (player != null)
        {
            // Find the top point of the terrain
            float highestYPos = float.MinValue;
            foreach (GameObject tile in terrainTiles)
            {
                if (tile.transform.position.y > highestYPos)
                {
                    highestYPos = tile.transform.position.y;
                }
            }

            // Move the player to the top of the terrain
            player.transform.position = new Vector3(player.transform.position.x, highestYPos + 0.5f, player.transform.position.z);
        }
        else
        {
            Debug.LogError("No player object found with tag 'Player'");
        }

        // Resize the camera to fit the generated terrain
        //Camera.main.orthographicSize = tileCount / 2.0f;
        Camera.main.orthographicSize = (tileCount / 2.0f) - 15.0f;
        Camera.main.transform.position = new Vector3(tileCount / 2.0f - 0.5f, maxHeight / 2.0f + bottomLayerHeight / 2.0f, -10.0f);
    }

    void GenerateTerrain()
    {
        // Delete any existing terrain tiles
        foreach (GameObject tile in terrainTiles)
        {
            tile.GetComponent<TerrainHealth>().Die();
        }

        // Generate new terrain tiles
        terrainTiles.Clear();

        GameObject tilePrefab = new GameObject("TerrainTile");
        SpriteRenderer renderer = tilePrefab.AddComponent<SpriteRenderer>();
        renderer.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0, 0, 1, 1), new Vector2(0.5f, 0.5f));
        renderer.color = terrainColor;

        // Set the scale of the tile prefab
        tilePrefab.transform.localScale = new Vector3(100, 100, 1);

        BoxCollider2D collider = tilePrefab.AddComponent<BoxCollider2D>();
        collider.size = new Vector2(0.01f, 0.01f);

        // Generate the bottom layer
        for (int i = 0; i < tileCount; i++)
        {
            GameObject bottomTile = Instantiate(tilePrefab);
            bottomTile.transform.position = new Vector3(i, bottomLayerHeight, 0);
            bottomTile.GetComponent<SpriteRenderer>().color = bottomLayerColor;

            TerrainHealth health = bottomTile.AddComponent<TerrainHealth>();
            health.health = Random.Range(minHealth, maxHealth);

            terrainTiles.Add(bottomTile);
        }

        float prevYPos = bottomLayerHeight;

        // Generate the rest of the tiles
        for (int i = 1; i < tileCount - 1; i++)
        {
            GameObject tile = Instantiate(tilePrefab);
            float noiseValue = Mathf.PerlinNoise(i * noiseScale, 0);

            float yPos = prevYPos + Random.Range(-heightRandomness, heightRandomness);
            yPos = Mathf.Clamp(yPos, bottomLayerHeight + 1, maxHeight);

            tile.transform.position = new Vector3(i, yPos, 0);

            // Set the size of the box collider
            collider.size = new Vector2(0.01f, 0.01f);

            // Fill the tiles between the terrain tile and the bottom layer tile
            for (int j = Mathf.FloorToInt(bottomLayerHeight) + 1; j < yPos; j++)
            {
                GameObject subTile = Instantiate(tilePrefab);
                subTile.transform.position = new Vector3(i, j, 0);

                TerrainHealth subHealth = subTile.AddComponent<TerrainHealth>();
                subHealth.health = Random.Range(minHealth, maxHealth);

                terrainTiles.Add(subTile);
            }

            // Add the health component to the terrain tile
            TerrainHealth health = tile.AddComponent<TerrainHealth>();
            health.health = Random.Range(minHealth, maxHealth);

            terrainTiles.Add(tile);

            prevYPos = yPos;
        }

        // Destroy the tile prefab
        Destroy(tilePrefab);
    }
}