2d camera movement

I want to have a threshold where the camera wont move until the object being tracked goes beyond a certain value. My pseudo code looks like this:

var thresholdX = 5;
var thresholdY = 5;

function Update(){
if(target.position.x > thresholdX){
//do the lerp transition
transform.position.x = Mathf.Lerp(transform.position.x, target.transform.position.x + 20, Time.deltaTime);

The problem is it’s only applying the transition in one frame. Is there any other way I could achieve this? Something like path based camera.

Instead of allways lerping to a certain amount, why not just clamp the camera? It might be a bit jolty, but you can allways apply smoothing form there.

//Instead of Lerp, use clamp
//This is just for moving along the X axis, similarly it would have to be done for other axis
transform.position.x = Mathf.Clamp(transform.position.x, target.position.x + thresholdX, target.position - thresholdX);

Hope this helps,