Drag Vertices of mesh with mouse

I want to do something like this video.


I am stuck at this, would appreciate any help or guidance. Thanks

This is my code so far:

public class MeshDeformation : MonoBehaviour {

	MeshFilter mf;
	Vector3[] verts;
    
    public Vector3 value = new Vector3(0.01f,0.01f,0.01f);

	void Start () {
		mf = GetComponent<MeshFilter>();
        verts = mf.mesh.vertices;
        Debug.Log("Vertices" + verts.Length);
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetMouseButton(0))
		{
			RaycastHit hit;
			Vector3 input = Camera.main.ScreenToWorldPoint(Input.mousePosition);
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
          
			if(Physics.Raycast(ray,out hit, 300))
			{
				Vector3 hitVertices = FindNearestPoint(hit.point);
                RaisePoint(hitVertices,value);
                Debug.Log("coming inside");
			}
		}
	}
	private Vector3 FindNearestPoint(Vector3 point)
    {
        Vector3 NearestPoint = new Vector3();
        float lastDistance = 99999999f;

        for (int i = 0; i < verts.Length; i++)
        {
            float distance = GetDistance(point, verts*);*

if (distance < lastDistance)
{
lastDistance = distance;
NearestPoint = verts*;*
}
}
return NearestPoint;
}
private float GetDistance(Vector3 start, Vector3 end)
{
return Mathf.Sqrt(Mathf.Pow((start.x - end.x), 2) + Mathf.Pow((start.y - end.y), 2) + Mathf.Pow((start.z - end.z), 2));
}
private void RaisePoint(Vector3 point, Vector3 val)
{
int index = -1;
for (int i = 0; i < verts.Length; i++)
{
if (verts == point)
{
index = i;
break;
}
}
if (index == -1)
{
Debug.LogError(“Could not match points”);
}
else
{
Vector3 newPoint = verts[index];
newPoint += val;
verts[index] = newPoint;
// mf.mesh.Clear();
mf.mesh.vertices = verts;
mf.mesh.RecalculateNormals();
mf.mesh.RecalculateBounds();

}
}
}

Hi, I’m working on a similar project right now. Unfortunately I haven’t managed to make it work yet… have you found any solutions in the meantime?
greets