- Home /
How to create youtube 360 vr flat cardboard behaviour in unity
Hi Guys,
We've been struggling around trying to recreate the same input behaviour you have when viewing a 360 video in youtube when using your mobile device in flat mode (viewing while holding it in your hands).
The issue is we can not swipe the screen without messing the rotation of the camera. We are using GVR SDK, so we basically have the camera moving by the gyro managed by GVR, and we swipe the parent of the Camera GameObject (since that game object is always updated by the GVR each frame).
This means the parent has a certain "swiping" rotation and the child (camera) has a gyro rotation. The swiping input should basically rotate the parent, but the axis by which we rotate (X and Y) should actually be those of the child object. The results we are getting are a always messed up.
Anyone has any idea as to how to achieve this?
Cheers!
NOTE: In order to check what I mean you have to watch a 360 video from youtube in your device and make sure it is not in "cardboard" mode.
Answer by GuyTidhar · Jan 22, 2017 at 07:30 AM
My solution involved two things: 1) Change the rotation of the GVRHead through the callback they supply. 2) Most importantly: use Quaternions! You can read Euler angles if you wish to detect when confine your rotations for instance, but do not set the rotation as Euler - only as Quaternions. This keeps away the annoying jittering.