unity2d camera moves when player goes specific distance,unity camera follow

Hi! im making a sidescroller 2d game and cant figure out to how to the make camera move when my player moves a specific amount of distance.

The idea is that when the player is at the edge of the screen(on the right side of the screen for example), the camera would move and draw more of the level on the right so the player would be on the left side of the screen again. Sorry for the awful explanation. Any ideas?,

Have you checkout out the cinemachine (cinemashine?) package?

I hope this is what you want @Jonttu56 :

using UnityEngine;

public class CameraFollow : MonoBehaviour
{
    [SerializeField] Transform player;
    [SerializeField] float timeOffSet;
    [SerializeField] Vector3 posOffSet;

    private Vector3 velocity = Vector3.zero;

    [SerializeField] Vector2 minCameraPos;
    [SerializeField] Vector2 maxCameraPos;

    private void Start()
    {
        transform.position = posOffSet;
        if (GameObject.FindGameObjectWithTag("MinCameraBounds"))
        {
            minCameraPos = GameObject.FindGameObjectWithTag("MinCameraBounds").transform.position;
        }
        if (GameObject.FindGameObjectWithTag("MaxCameraBounds"))
        {
            maxCameraPos = GameObject.FindGameObjectWithTag("MaxCameraBounds").transform.position;
        }
    }

    [SerializeField] Vector3 _target;
    [SerializeField] Vector3 _beforePosition;
    [SerializeField] Vector3 _afterPosition;

    void Update()
    {
        Vector3 target = new Vector3(player.position.x, player.position.y, posOffSet.z);
        _target = target;

        transform.localPosition = Vector3.SmoothDamp(transform.localPosition, target, ref velocity, timeOffSet);
        _beforePosition = Vector3.SmoothDamp(transform.localPosition, target, ref velocity, timeOffSet);

        transform.localPosition = new Vector3(Mathf.Clamp(transform.localPosition.x, minCameraPos.x, maxCameraPos.x),
            Mathf.Clamp(transform.localPosition.y, minCameraPos.y, maxCameraPos.y), posOffSet.z);
        _afterPosition = new Vector3(Mathf.Clamp(transform.localPosition.x, minCameraPos.x, maxCameraPos.x),
            Mathf.Clamp(transform.localPosition.y, minCameraPos.y, maxCameraPos.y), posOffSet.z);
    }


}