Forum Discussion
AADProductions
10 years agoExplorer
Best practice for camera rotation offset in Unity 5
I'm working on a game where you spend a lot of time looking down and it's making people a bit uncomfortable. I'd like to add a 45° offset to the camera's x rotation to take the strain off their necks ...
peterept
10 years agoProtege
I think what you want is not technically supportable until Unity seperates the VRCameraTransform and the InputTracker.
The crucial thing is the ordering of quaternion rotations. You need to apply your offset after the camera orientation.
But, that said... you could *cough* hack it *cough*...
Not pretty but, parent the camera with 2 levels. First parents job is to nullify any rotations and position changes the unity is applying on the VR Camera. Grandparents job is to apply the VR.InputTracking.GetLocalRotation(VRNode.CenterEye) and add your offset.
This is working for me, and I think it achieves what you described - when I look around the horizon stays level, but I am at a 45 degree down angle. (It's a bit weird though - so it depends on your game).
To nullify the VRCam:
To apply the VR orientation (could apply position as well)
Unity package attached.
The crucial thing is the ordering of quaternion rotations. You need to apply your offset after the camera orientation.
But, that said... you could *cough* hack it *cough*...
Not pretty but, parent the camera with 2 levels. First parents job is to nullify any rotations and position changes the unity is applying on the VR Camera. Grandparents job is to apply the VR.InputTracking.GetLocalRotation(VRNode.CenterEye) and add your offset.
This is working for me, and I think it achieves what you described - when I look around the horizon stays level, but I am at a 45 degree down angle. (It's a bit weird though - so it depends on your game).
To nullify the VRCam:
public class NullifyTransform : MonoBehaviour {
public Transform t;
void LateUpdate () {
if (t != null)
{
transform.localRotation = Quaternion.Inverse(t.localRotation);
transform.localPosition = -t.localPosition;
}
}
}To apply the VR orientation (could apply position as well)
public class VRTransform : MonoBehaviour {
void Update () {
transform.localRotation = InputTracking.GetLocalRotation(VRNode.CenterEye) * Quaternion.Euler(45, 0, 0);
}
}
Unity package attached.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 years agoAnonymous
- 11 months ago
- 5 months ago
- 2 years ago