How to make one movement direction be equal to diferent cameras?

Hello,

I have 4 cameras, each camera represents a player, so, I have player one camera, player two camera, player three camera, and finaly, player four camera. All cameras are lookingAt() same target. I have a UI with two buttons, one to make camera RotateArround() the target, like in a orbit, but only moves in one direction, and the second button its to make camera RotateArround() the target and move it backwards to the initial position in the inverse direction.

What’s the problem?
The problem it’s that I can rotate with player one camera arround the target but when I change to player two, three or four, the cameras start rotating in wrong directions. This is because every camera as its own rotation and position values, so moving a axis one camera brings diferents results in every camera.


Examples

Behaviours:

Cameras Controll script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cameraControll : MonoBehaviour
{

    private GameObject lookAtTarget;

    private int speed = 0;
    
    private float zoomSmoothness = 0;
    private float minZoom = 0;
    private float maxZoom = 0;

    private float maxRotationX = 0;
    private float minRotationX = 0;

    public void moveUp()
    {
        if (lookAtTarget == null)
        {
            Debug.LogError("Camera target it's null");
            return;
        } 

        if (transform.rotation.x > maxRotationX)
        {
            return;
        }

        Debug.Log("Current position: " + transform.position + " Current rotation: " + transform.rotation);
        transform.RotateAround(lookAtTarget.transform.position, new Vector3(0, 0, transform.position.z + 1), Time.deltaTime * speed);
    }

    public void moveDown()
    {
        if (lookAtTarget == null)
        {
            Debug.LogError("Camera target it's null");
            return;
        }

        if (transform.rotation.x < minRotationX)
        {
            return;
        }

        transform.RotateAround(lookAtTarget.transform.position, Vector3.left, Time.deltaTime * speed);
    }

    public void zoomIn()
    {
        GetComponent<Camera>().fieldOfView = Mathf.Lerp(GetComponent<Camera>().fieldOfView, minZoom, Time.deltaTime * zoomSmoothness);
    }

    public void zoomOut()
    {
        GetComponent<Camera>().fieldOfView = Mathf.Lerp(GetComponent<Camera>().fieldOfView, maxZoom, Time.deltaTime * zoomSmoothness);
    }

    
    //Setters && Getters\\

    public void setLookAtTarget(GameObject lookAtTarget)
    {
        this.lookAtTarget = lookAtTarget;
    }

    public void setSpeed(int speed)
    {
        this.speed = speed;
    }


    public void setMinZoom(float minZoom)
    {
        this.minZoom = minZoom;
    }

    public void setMaxZoom(float maxZoom)
    {
        this.maxZoom = maxZoom;
    }

    public void setZoomSmoothness(float zoomSmoothness)
    {
        this.zoomSmoothness = zoomSmoothness;
    }

    public void setMaxRotationX(float maxRotationX)
    {
        this.maxRotationX = maxRotationX;
    }

    public void setMinRotationX(float minRotationX)
    {
        this.minRotationX = minRotationX;
    }
}

Any solutions?

Thank you in advance.

This is a fantastic question and I must ask a favour of you to please re-ask it on the Cinemachine forums. That’s where we discuss everything CM.

Please ask again here: https://forum.unity.com/forums/cinemachine.136/

Thanks so much,
Adam

For those with the same question, here is a link to the new thread: https://forum.unity.com/threads/how-to-make-one-movement-direction-be-equal-to-diferent-cameras.539452/