Camera doesn't stop moving

I want my camera to move with my mouse and every where I looked they say to use Camera.main.ScreenToWorldPoint(Input.mousePosition)

but with my code

    using UnityEngine;
    using System.Collections;

    public class Camera_Follow : MonoBehaviour {

        Camera cam;
    	// Use this for initialization
        void Start () {
	        cam = GetComponent<Camera> ();
    	}

        // Update is called once per frame
    	void FixedUpdate () {
        	Vector3 tarPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
	        tarPos.z = -10f;
    		transform.position = Vector3.Lerp (transform.position, tarPos, .1f);
        }
    }

the camera never stops. I assume what is happening is that the camera doesn’t reach the mouse ever, but I don’t know why this will be happening or how to stop it. Can someone help?

You’re moving the camera every frame towards a point relative to the camera itself. Think of it as a dog chasing its own tail. As the camera moves, so does the point, thus if will never reach the point.

I’m not sure exactly what effect you are trying to achieve, but if you want to manually control when the camera moves, perhaps for debugging purposes, you can wrap your camera movement code into an if-statement like so:

void FixedUpdate () {
    if (Input.GetMouseButton(0)) {
        Vector3 tarPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        tarPos.z = -10f;
        transform.position = Vector3.Lerp (transform.position, tarPos, .1f);
    }
}

This allows you to only move the camera while you’re holding down your mouse left button.

Thanks for the help, I wanted my cam to follow my mouse’s movement.
I solve the problem by having another camera that doesn’t move for the Screentoworld part and have and object move according to that cam and have the main cam follow the object.