How do I move the camera to another object in the scene on mouse down?

I want to attach a script to my object that when I click on that object, the camera moves to another object.

So, currently my main camera is focused on one object but I want that camera to move when I click on a specific object and land on another object.

I was thinking since i have the coordinates of both objects, I can move the camera on mouse down from coordinate (x1, y1, z1) to (x2, y2, z2) but I’m not sure how or what function to use.

Add a script to your clickable objects that says:

var mainCam:Camera;

function OnMouseUp() {
   mainCam.transform.position = new Vector3(transform.position.x, transform.position.y, mainCam.transform.position.z); 
}

Make sure to drag your main camera to the mainCam field in the inspector. I left the Z position on the camera the same since I figured your may want to keep the distance away from the object the same, and just adjust the X/Y.