Is there a line of code for locking the cemera in place?

Hey, my cemera is following the player and its all good and dandy.
But I want for it to be able to detect a door for example, and untill it opens, when the player gets close, he can’t see anything after it.
So I’ve written the detetction part, but I’m looking for a way to lock the cemera in place and unlock it when you get close and get far from the door, is ther a way to do so?

`

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraBoundry : MonoBehaviour
{
private bool IsBounded;
public Transform _cameraPosition;
public float checkRadius;
public LayerMask whatIsBoundry;
GameObject mainCamera;

void Start()
{
    mainCamera = (GameObject)GameObject.FindWithTag("MainCamera");
}


void FixedUpdate()
{
    IsBounded = Physics2D.OverlapCircle(_cameraPosition.position, checkRadius, whatIsBoundry);
    if (IsBounded == true)
    {
        mainCamera.transform.position = new Vector3();
    }
}

}

Has anyone have an idea?

Idk

    void update()
    {
//if the camera doesn't have a parent
    mainCamera.transform.position = Quaternion.Identity
    }

or

 void update()
    {
//if the camera has a parent
    mainCamera.transform.localPosition = Quaternion.Identity
    }

This just keeps it in the same place, nothing else. And If it doesn’t work some one else will have to correct me, to lazy to test the code :confused: