Amplifying HMD rotation in VR

I am trying to amplify the rotation of the Camera in VR. Essentially, if you look 15 degrees to the left, the camera actually turns 30 degrees.

To rotate the camera, I am using a parent object and manipulating the parent transform.

My current solution uses Euler angles, which is causing a lot of problems due to the flip from 0 to 360 degrees. I have tried to mitigate this in my code, but when the HMD is pointed straight up or straight down, the camera ends up tilted somehow.

I figure quaternions will help fix this, but I am finding it difficult to implement a solution as I don’t know how to scale a quaternion. I also can’t find a similar function to RotateAround using quaternions. [I think] I need this function as the parent transform I am rotating isn’t in the same position as the camera.

My current solution simply takes the change in euler angles between frames, and scales it by a factor. See below:

[ICODE]

void ApplyRedirection(Vector3 newOrientation, Vector3 curOrientation)
{
   
    float changeInPitch = newOrientation.x - curOrientation.x;
    if (changeInPitch > 200)
    {
        changeInPitch -= 360;
    }
    if(changeInPitch < -200)
    {
        changeInPitch += 360;
    }
    PitchChange = changeInPitch;
    camOffset.transform.RotateAround(currentHeadPosition, new Vector3(0, currentHeadOrientation.y, 0), changeInPitch * redirectionIntensityP * Time.fixedDeltaTime);

    float changeInYaw = newOrientation.y - curOrientation.y;
    if (changeInYaw > 200)
    {
        changeInYaw -= 360;
    }
    if (changeInYaw < -200)
    {
        changeInYaw += 360;
    }
    YawChange = changeInYaw;
    camOffset.transform.RotateAround(currentHeadPosition, new Vector3(0, currentHeadOrientation.y, 0), changeInYaw * redirectionIntensityY * Time.fixedDeltaTime); //Do yaw reditection (horizontal)

    currentHeadOrientation = newOrientation;
   
}

[/ICODE]

Hello, i have the same issue… have you finally found the proper way of doing this?

Hi there @Trqncescqpe . No, I ended up using an acceleration instead of a direct amplification of the movement. Essentially, I measured the distance over several frames and integrated to get a speed. Then I used this variable to scale the rotation. This stops the skew or at least makes it possible to fix by making fast rotations. Here is the acceleration version:

 void ApplyRedirection(Vector3 newOrientation, Vector3 curOrientation)
    {
        float changeInPitch = newOrientation.x - curOrientation.x;
        if (changeInPitch > 200)
        {
            changeInPitch -= 360;
        }
        if (changeInPitch < -200)
        {
            changeInPitch += 360;
        }
        PitchChange = changeInPitch;
        accelerationP = Mathf.Clamp(Mathf.Abs((angleChange[1, 0] + angleChange[1, 1] + angleChange[1, 2] + angleChange[1, 3] + angleChange[1, 4]) / 25 * redirectionIntensityP), 0, redirectionIntensityP);

        camOffset.transform.RotateAround(currentHeadPosition, new Vector3(0, currentHeadOrientation.y, 0), changeInPitch * accelerationP * Time.fixedDeltaTime);

        float changeInYaw = newOrientation.y - curOrientation.y;
        if (changeInYaw > 200)
        {
            changeInYaw -= 360;
        }
        if (changeInYaw < -200)
        {
            changeInYaw += 360;
        }
        YawChange = changeInYaw;
        accelerationY = Mathf.Clamp(Mathf.Abs((angleChange[0, 0] + angleChange[0, 1] + angleChange[0, 2] + angleChange[0, 3] + angleChange[0, 4]) / 25 * redirectionIntensityY), 0 , redirectionIntensityY);

        camOffset.transform.RotateAround(currentHeadPosition, new Vector3(0, currentHeadOrientation.y, 0), changeInYaw * accelerationY * Time.fixedDeltaTime); //Do yaw reditection (horizontal)

        updateAngles(changeInYaw, changeInPitch);

        currentHeadOrientation = newOrientation;
}

Thanks for the code… that I absolutely not understand haha. I spoke with some folks and increasing the rotation could increase the motion sickness so what I will do is controlling the rotation with the controller axis instead. Thanks for the help