How would I script the camera to zoom in on one player and then to another?

I’m working on a game for class and I was wondering how I can go about scripting the camera to zoom in and pan from one player to another.

What I had in mind was I’d want the camera to zoom in on Player A when he dies and then drastically pan and zoom in on Player B who is still alive, after a few seconds of focus on Player A.

You can make the camera’s transform LookAt another object to point at it accurately- some combination of that and normal panning (translate in local X directions over time) or RotateAround seems like it should work fine.

If you need the camera to move from one specific position to another, you can shortcut this by tracking key locations for possible camera positions- setting up empty child GameObjects on players, the sole purpose of which is to act as special relative positions for the camera to move to. So, for instance, make a new camera object as a child of the player, move the camera around to the position you WANT the camera to have, later (like, “just to the right of the player’s head, looking at their face from the side”), then delete the camera component and just keep the transform- then that transform can act as a key point for the real game camera to move to later. Just translate from the camera’s ‘current position’ to the ‘target position’, while also slowly turning the camera from the ‘current rotation’ to the ‘LookAt’ rotation as well, and that should do it.

Definitely check out Cinemachine though- there’s a system in there that already does absolutely all of this for you.