How to freeze a character controller camera

Ok so i have this awesome keypad script finally finished thanks to all the help i have received on here, and now i’ve been asked to update it to handle some camera controls. What i need is to be able to turn off me MouseLook script and center the Main Camera on my First Person Character Controller. this way the camera is facing the directly at the door, and it wont move while the player interacts with the keypad gui. ive looked at lots of different examples but i haven’t been able to get anything to work. any help would be much appreciated, and if possible i would prefer all answers in C#. im afraid i dont have any starting code to work with.

For your camera movement, you’ll want a script that is able to manipulate its position and rotation. If you simply need the camera to behind and looking at the player, assuming you’re storing a reference to the player’s gameObject you can set up something like this:

//you should probably declare these floats as constant fields
float prefferredCamDist = 5f; 
float arbitraryLerpModifier = 0.5f;

Vector3 desiredPosition = playerObject.transform.position - playerObject.transform.forward*prefferredCamDist;
//In this case, the desired position is DIRECTLY behind the player - you may wish to add a y component so the desired
//position is also slightly above the player

//From here, you can either make the camera jump to the desired position, or you can use Lerp / SmoothDamp for smooth motion
//In this example, I'll use lerp
this.transform.position = Vector3.Lerp(this.transform.position, desiredPosition, arbitraryLerpModifier); 
//increase the value of arbitraryLerpModifier modifier to increase the speed at which your camera approaches the desired position
//Multiply by Time.deltaTime if you want your camera's motion to be time dependant

Quaternion desiredRotation = Quaternion.LookRotation(playerObject.transform.position - this.transform.position);
//alternatively, if you want to look directly at the keypad, change playerObject to your keyPadObject
//From here, again, you can have the camera look directly at your target, or you can use smoothing
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, desiredRotation, arbitraryLerpModifier);

Just make sure that you only reach this code when it’s relevant, i.e. if your KeyPadEnabled variable is true. Otherwise, use your normal camera code.