How do i align my camera with a gameobjects x and y axis?

(Im fairly new to Unity)
Ok so i have these 2 rooms and i have the camera looking at the first room.


I want it so that when the player enters the second room, the camera moves its view to the other room
(in a 2D perspective)



Ive tried using a box filling the room acting as a trigger, and OnTriggerEnter it would align the camera’s x and y axis with the box trigger’s axis. (But not the Z so it keeps the distance) but so far i have had no luck at all. and i have screwed around with the code so much now that i even find it irrelevant to post. Can anyone come up with a script that could do this, it would be MUCH appreiciated.

I’d parent your camera to a game object (lets call it “CameraParent”) and set the “CameraParents” position to the room1’s position, then back your camera up to the distance and angle you want it to be. When your Player hits the trigger call a function to move the “Camera Parent” object to the next room

Possible Example:

void OnTriggerEnter(Collider collider)
	IEnumerator MoveCameraToNextRoom()
		float t = 1;
		while(t > 0)
			cameraParent.position = Vector3.Lerp(oldRoom.position, newRoom.position, t);
			t -= Time.deltaTime;
			yield return null;

(not tested)