Controlling Distance with RotateAround

I have an independent camera rotating around a player object with Transform.RotateAround based on the mouseX and mouseY.

What’s the best way (without parenting camera to player - code only), to make sure the camera always repositions itself a certain distance behind the player, based on that angle?

Here’s what I was trying but it leaves my camera frozen behind the player. Any thoughts?

`function LateUpdate () {

//CAMERA INPUT
this.transform.RotateAround(target.transform.position, Vector3.up, baseLookSpeed * Input.GetAxis("Mouse X")); //mouse x input
	this.transform.RotateAround(target.transform.position, Vector3.right, baseLookSpeed * Input.GetAxis("Mouse Y"));  //mouse Y input
	
    //rotate player to match.
    target.transform.eulerAngles.y = this.transform.eulerAngles.y; //rotate player to match camera angle.


    //POSITION CAMERA
    var newCamPosition:Vector3 = target.transform.position + (Vector3.back * distToPlayer);    //this line freezes cam behind player.
    this.transform.position = newCamPosition;               

    //rotate & angle camera
    transform.LookAt(target.transform); //look at the player.

You can do this in a number of different ways, but the simplest might be to change line 12 to:

     var newCamPosition:Vector3 = target.transform.position - (target.transform.forward * distToPlayer);