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);