camera follow

Good morning, how can I make the camera follow the character, but just follow it from side to side so when the camera jumps do not jump too.

Thank you.

Try this :

public gameObject target; //your player gameobject
private Vector3 targetPos; //the new destination
private float smoothTime = n; //set it as you want

void Update(){
   targetPos = new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z); 
//Here its our Vector3, only the y axis will be always the same, but the others axis are equal to the player x,z axis

       transform.position = Vector3.lerp(transform.position, targetPos, smoothTime * Time.deltaTime);
//Change the current position by our Vector3

I havent test it but it should work