Change Orientation of Camera

Hi all,

I’m trying to change the scale of the rotation of the VR camera, based on the Oculus’ tracker. Eg, with a scale of 2.0, when I rotate my head 30 degrees, the camera should be rotated 60 degrees. I am currently only interested in yaw (look left/right). So far, I have been unable to implement it.

I worked with both OVRCameraRig and only a single camera with a script attached. The script just read the current eulerAngles of the camera’s rotation, multiply it by a fixed scale and set it again. However, it seems the camera ignores the new values. They appear in the debugger, but I do not see any difference. I tried the code in the preRender, preCull, lateUpdate methods with no effects.

The code looks like this:

void OnPreCull() {
float yaw = transform.eulerAngles[1];
yaw *= yawScale;
transform.rotation = Quaternion.Euler(0.0f, yaw, 0.0f);
}

Secondly, I tried rotating the scene opposite the rotation. However, that does not update the Skybox and the rotation also appeared jerky and certainly not smooth. I tried that in the update method.

Any tips and help would be much appreciated :slight_smile: I’ve been banging my head against this problem for the last 2 days.
Cheers!

Hmm, it looks like Unity is ignoring/overwriting any changes to the rotation of the camera object. Is there anyway to disable this behavior?

You cannot change the transform of the camera, however you can make a parent object for the camera and then change the parent object’s transform.

Thanks but that did not work. The rotation of the camera gets very jerky if I try that. To be clear: ideally I want to set the entry camera’s transformation myself.