Cant get the player to rotate in the direction of movement with orbital camera. (Tried a few solutions with no result)

Hello fellow unity devs, im using my own topdown controller for my game, I use translate to move the character relative to the camera above the player. The camera is not attached to the player and follows with its own script which also allows 360 degrees rotation on the y axis (so you can orbit around the player). Now I need the player to look in the direction it is moving, if i use input.getaxis It doesnt work once you move the camera, x and z will always work in the worldspace and will always point the same directions for wasd. I also tried using the attached rigidbody’s velocity but it returns 0,0,0 until i hit a wall which it then returns a whole bunch of weird numbers that make the player continually spin in circles. Here are some of the scripts I tried using. For context the moveVelocity is inputxaxis,0,inputyaxis and cameraRotation is the transform that the main camera is attached to which follows the players position but not rotation. Any help, or ideas would be greatly appreciated as all I could find online were solutions using the input.getaxis and none of them have worked so far.

Also ive tried changing up these scripts removing the +cameraRotation, trying to change what gets rotated and where it gets the values to rotate too from with no luck.

transform.rotation = Quaternion.LookRotation(new Vector3(moveVelocity.x + cameraRotation.rotation.x, 0f, moveVelocity.z + cameraRotation.rotation.z) * Time.deltaTime);

            transform.rotation = Quaternion.Slerp(transform.rotation,
            Quaternion.LookRotation(new Vector3(moveVelocity.x + cameraRotation.rotation.y, 0f, moveVelocity.z + cameraRotation.rotation.y) ) , rotateSpeed);

Also here is the code for the entire movement

public float moveSpeed = 10;
    public float jumpForce = 10;
    public float rotateSpeed = 0.15f;
    private Rigidbody m_Rigidbody;
    private Vector3 moveInput;
    private Vector3 moveVelocity;

    private Vector3 input;
    private Camera mainCamera;
    private Transform cameraRotation;

    private void Start()
    {
        m_Rigidbody = GetComponent<Rigidbody>();
        mainCamera = Camera.main;
        cameraRotation = GameObject.FindGameObjectWithTag("CameraPivot").GetComponent<Transform>();
    }

    private void Update()
    {
        GetInput();
        moveInput = new Vector3(Input.GetAxis("Horizontal"), m_Rigidbody.velocity.y, Input.GetAxis("Vertical"));
        moveVelocity = moveInput * moveSpeed;
    }

    void GetInput()
    {
        input = new Vector3(Input.GetAxis("Horizontal") * moveSpeed, 0, Input.GetAxis("Vertical")) * moveSpeed;
        if (Input.GetKeyDown(KeyCode.Space))
        {
            m_Rigidbody.velocity = new Vector3(0, jumpForce, 0);
        }
    }
    private void FixedUpdate()
    {
        Vector3 playerMovement = input * moveSpeed * Time.deltaTime;
        transform.Translate(playerMovement, cameraRotation);
        

        if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation,
                Quaternion.LookRotation(new Vector3(moveVelocity.x + cameraRotation.rotation.y, 0f, moveVelocity.z + cameraRotation.rotation.y) ) , rotateSpeed);
           
        }
    }

Hello.

You only need to calculate the vector “Direction”.

As camera only rotates in 1 axis, is simple, like with positions.

If:

objt A is at worldposition 5
objt B is at worldposition 7
If i ask you where is B respect to A, you will do 7-5 = 2
From A position, B is at "localposition" 2

Now change the order to fit in our case:

What is the real position of B if the only thing i know is from A is at 2 and A have a rot of 5

Easy!

So now, lets do the same with rotations.

The question is What is REALROT of Player if FromCamera the rotation is “RELATIVEROT” and the camera itself rotation is “CAMROT”

RealRotation = CAMROT +  RELATIVEROT
 or
RELATIVEROT = REALROT - CAMROT

Do you see where I’m going?

Bye!