Change speed value depends on the mouse position from the center

I change (screen edge movement) the position of the camera on mouse movement to a specified boundary, I want to reduce the speed of the camera according to the mouse position from the center.
make the speed = 0 if the mouse is on the edge, and speed =10 while the mouse is at the center with respect to the in between values.

Here is a starting point:

void Update () 
        // calculate speed based on camera relation to mouse
        float speed = Vector2.Distance(Camera.main.transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition));

        // get the mouse postition with your camera z (so your camera doesn't change depth)
        Vector3 mousePosition = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y, Camera.main.transform.position.z);

        // move the camera towards the mouse by calculated speed
        Camera.main.transform.position = Vector3.MoveTowards(Camera.main.transform.position, mousePosition, speed * Time.deltaTime);

Good luck! :slight_smile: