Cardboard camera issues
Hi everyone,
I'm currently designing a rollercoaster type test app using google cardboard and i'm running into a small issue that I can't seem to find an answer to, basically I have a parent object follow a set of waypoints which works fine and I have the cardboard cameras set as a child of that object.
Now the head rotations work fine and the camera rotates as the parent rotates, but the cameras don't face the direction the parent is travelling in, the cameras always seem to be locked looking north, i.e the parent turns 90 degree to the left but the camera always stays at 0 degrees.
Is there a way to update the cardboard head to looking in the same direction as the parent object, say if the user turns their head slightly off to the right and the parent turns the corner that when the user moves their head back forward then the camera is at the same angle as the parent.
I've also tried the "target" variable on the CardboardHead script but that didn't work either.
Cheers
When you say the camera rotates as the parent rotates, you mean only on certain axes?
I find when I point the "target" property to a GameObject the camera moves and rotates to match the target but it seems the camera axes get rotated. This target is not a parent and the only relation is through the "target" property.
Rotating the target on the y-axis by 90 degrees will cause the cameras to roll ins$$anonymous$$d of pitch when I nod my head up and down. Rotating on the y-axis by 180 degrees will cause the cameras to pitch in the opposite direction when I nod my head.
Are you experiencing anything like that?
Answer by jonathanasdf_google · Sep 22, 2015 at 04:44 PM
In the v0.5.1 and earlier releases there's a silly bug that causes this when using the target property. It's a one-line fix, so you can try it out yourself (it'll be fixed in an upcoming release). In CardboardHead.cs, in the function UpdateHead(), change this:
transform.rotation = rot * target.rotation;
to this:
transform.rotation = target.rotation * rot;
Ah heck. I manage the account name this answer was posted under, and forgot I was logged in with it when I wrote the above. That was me.
I swear I looked at that line a few days ago and wondered if the order was right but never got around to testing. quaternion multiplications are not commutative. thanks @dolims!
In the Cardboard SD$$anonymous$$ reference, I think the behavior of the target property could be better defined:
A target object may be specified to provide an alternate reference frame for the motion.
This was not enough for me to go on to deter$$anonymous$$e whether my target object was acting as intended.
$$anonymous$$ay I suggest something to the effect of: Head tracking position and rotation will be relative to the position and rotation of the target object's transform.
As an example, my specific use case is within a 360 panorama viewer, the user should be able to rotate her virtual body to see what's behind her head. This would come in handy if I'm using the app in a situation where I can't physically turn all the way around like on a bus or airplane.