- Home /
Controlling flight direction from OVR head rotation
I am trying to make a flight controller with the OVRCameraRig prefab, where the plane forward direction will be equal to the OVR eye forward direction.
I have a "Plane" gameObject with the OVRCameraRig as it's child.
The Plane object has the following script attached to it:
Quaternion rotation = OVRRig.rightEyeAnchor.transform.localRotation;
Quaternion combinedRotation = transform.rotation * rotation;
Quaternion relative = Quaternion.Inverse(transform.rotation) * combinedRotation;
transform.rotation = relative;
With this approach the plane does turn but only a fraction of the actual head rotation. For instance if looking on the right at 90degrees, the plan with steer right by lets say 40degrees.
I've also tried simpler approaches like:
Quaternion rotation = OVRRig.rightEyeAnchor.transform.localRotation;
transform.rotation *= relative;
This results with the plane incrementing its rotation by the amount or head rotation on every frame. Let's say i look 20degrees on the right the plane will keep turning around until I look straight. A little like having a joystick.
No matter what combination I try I always seems to end up with either of the above results, any help would be greatly appreciated.
Thanks