I’m using the google cardboard SDK and i have a script attached to the child “Head” in the GvrMain prefab. There’s also a Character controller connected and the vrCamera variable has been set to the “Head” object to this so that i can move the user based on the code which will follow.
Here is a link to what my scene looks like and what the head object looks like in unity and it’s configuration.
The issue i’m having is that i want to move the character when the user tilts their head at an angle, all this works fine but the issue is that when the simpleMove function is called nothing is happening… I’ve logged to see if any of the variables upto the point are empty but none of them seem to be; just this function doesn’t seem to be getting called. Code below.
public class VRLookWalk : MonoBehaviour {
public Transform vrCamera;
public float toggleAngle = 30.0f;
public float speed = 3.0f;
public bool moveForward;
private CharacterController myCC;
// Use this for initialization
void Start () {
myCC = GetComponent<CharacterController> ();
}
// Update is called once per frame
void Update () {
if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f)
{
moveForward = true;
} else {
moveForward = false;
}
if (moveForward)
{
Vector3 forward = vrCamera.TransformDirection (Vector3.forward);
myCC.SimpleMove (forward * speed);
}
}
}