Keeping a camera always at one side of 2 players

I’m trying to reproduce the Tekken camera for a fighting game. My two players can rotate around each other and excange sides. The camera always ajust its position and orientation based on the fighters’ values. I find the middle point of the fighters and use it to control the camera. My problem occurs when one of them jump over the other and they change sides, the camera also changes sides. I know this happens because I’m using the local right vector of one the fighters to place the camera, but I don’t know what to do to fix this problem. If I don’t use one of the local vectors, what else can I do? My code

Vector3 dir = mainTarget.position - sparring.position;
Vector3 center = mainTarget.position + dir.normalized * dir.magnitude / 2;

camera.transform.position = Vector3.Lerp(camera.transform.position, center + mainTarget.right * dir.magnitude + new Vector3(0, yOffset, 0), Time.deltaTime * translateSpeed);
Quaternion cameraRot = Quaternion.Slerp(camera.transform.rotation, Quaternion.LookRotation(center - camera.transform.position), Time.deltaTime * rotSpeed);
camera.transform.rotation = cameraRot;	
camera.transform.LookAt(center);

Sound like a very known problem called SORTING.

Problem:
Think of the two positions as values in a list. How do you determine which should be first?

Solution:
Check if A < B and if thats wrong, swap them (C=A;A=B;B=C now A and B is swapped) or write a second routine that uses the values oppersite, when A > B

is this usefull, then please mark my answer as the correct one. :o)

Welcome to this forum.