How to make the camera follow the character ?

How to make the camera follow the character on y axis only if the character passe by a determinated position?

Pseudo code, syntax YMMV

On camera,

if(DesiredPosition) {
 Vector3 newVect = Vector3(transform.position.x, player.position.y, transform.position.z);
 transform.position = newVect;
}

using UnityEngine;
using System.Collections;

public class yourClassName : MonoBehaviour {
       
        public Transform yourObject;
        
        void Update ()
        {
                  transform.position = new Vector3(yourObject.position.y + 6, 0, -10);
        }
}

This worked for me from Live training 20 @Caldas