Rotate a Quaternion any ideas

Hello,
I am working on a game in which the player character can walk on a “planet” like thing. Best reference is probably Mario Galaxy.
I am writing a camera controller for that however my Mouse input is not turning when the player is turning.
If I have vertical Input and the player is upright than i get vertical rotation. However if i have vertical Input and the player is turned sideways I get horizontal rotation.
I would like to rotate my input based on the players rotation.
Does anyone have any suggestions how to rotate a quaternion?
Or ideas how to do it differently?

Thank you very much for any suggestions or ideas.

void Input()
    {
        vertical = -Input_Manager.GetInput().right_XInput * camSpeedX;
        horizontal = Input_Manager.GetInput().right_YInput * camSpeedY;
    }

    void Follow()
    {
        rotVertical += vertical *  Time.deltaTime;
        rotHorizontal += horizontal * Time.deltaTime;
       
        Quaternion rotation = Quaternion.Euler(rotVertical, rotHorizontal, 0);

        // an Idea I had to always get the right Input vector relative to the player however I didnt know what to do from there
        Vector3 xpos = camTarget.transform.up * vertical;
        Vector3 ypos = camTarget.transform.right * horizontal;
        Vector3 pos = xpos - ypos;


        this.transform.localPosition = Vector3.Lerp(this.transform.localPosition, camTarget.transform.localPosition - (rotation * offset), speedSmooth * Time.deltaTime);



        this.transform.LookAt(lookAtTarget.transform, camTarget.transform.up);


       /*Ideas that didnt work
        * Quaternion rotation = Quaternion.Euler(rotVertical, rotHorizontal, 0);
        * Vector3 rotateQuaternion = rotation * (camTarget.transform.forward);
        * rotation = Quaternion.LookRotation(rotateQuaternion, camTarget.transform.up);
        * 
        * transform.RotateAround(camTarget.transform.position, camTarget.transform.up, vertical * Time.deltaTime);
        * transform.RotateAround(camTarget.transform.position, camTarget.transform.right, horizontal * Time.deltaTime);
        */
    }

What do you mean exactly?
There is two case I see, the camera is always behind the character, it’s easy to do.
The control are relative to the camera, which is hard.

For the first one, you basically parent the camera pivot to the character, first align the character to the planet normal direction, then just rotate the character like a flat surface. The camera just follow the pivot, use the orientation of the pivot to align camera.

For the second one I solved it there (took me 3 years)
https://gamedev.stackexchange.com/questions/53395/relative-cam-movement-and-momentum-on-arbitrary-surface

1 Like

Hey,
yes I am sorry i should have explained better. Its a third person camera that rotates around the player. the player movement and orientation on object is already working its just the camera that still gives me trubble.

It would be the second case the camera moves via mouse and only follows the player in position.
Thank you very much I will check it out. ^^