how to make flashlight follow mouse pointer in 2D?

Hello I was wondering how can i have this light follow my mouse pointer in a 2D project? so as you move the cursor the light would follow

Found an answer Luce Digitale | Blog Unity - Object follow cursor pointer
messed around with it and added a late update and converted to C#

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

public class LightFollowMouse : MonoBehaviour {



  
    public float depth = 10.0f;
    void LateUpdate()
    {
        FollowMousePosition();
    }

    void FollowMousePosition()
    {
        var mousePos = Input.mousePosition;
        var wantedPos = Camera.main.ScreenToWorldPoint( new Vector3(mousePos.x, mousePos.y, depth)); //you need a new vector3 because of the variables it takes XYZ Z= depth
        transform.position = wantedPos;
    }
    
   
}