I made update from Cardboard to GoogleVR so some code become deprecated.
I get the current head position of player to calculate the following user rotation. So what I need just to put player in front of image automatically. Here is an example:
moving player closer to picture
Vector3 spawnPos = hitObjectPos + hitObjectDirection * spawnDistance;
spawnPos = new Vector3 (spawnPos.x, transform.position.y, spawnPos.z);
player.transform.position = spawnPos;
calculate rotation
var headRotation = Cardboard.SDK.HeadPose.Orientation;
Quaternion lookAt = Quaternion.LookRotation (hitObject.transform.position - transform.position);
perform rotate as need
Vector3 rot = new Vector3 (0, lookAt.eulerAngles.y - headRotation.eulerAngles.y, 0);
player.transform.rotation = Quaternion.Euler (rot);
But now Cardboard.SDK.HeadPose.Orientation
is deprecated.
Does anyone find the alternative to find Head position?
Whenever there is a new plugin update, please read the release note before updating. The release note mentioned that many things has been renamed.
You are actually suppose to get namespace
error instead of warning. This means that you did NOT install the update the recommended way. Please delete the old cardbaord directories as instructed then download and import everything in the GoogleVRForUnity.unitypackage
.
It mentions that Cardboard.SDK
, is now GvrViewer.Instance
. So Cardboard.SDK.HeadPose.Orientation
should now be GvrViewer.Instance.HeadPose.Orientation;