Moving the user with google cardboard SDK
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.
https://drive.google.com/file/d/0B0QLbDLfJn6_dFBRTXpId09vaEU/view
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);
}
}
}
Answer by OpenXcell-Studio · Oct 17, 2016 at 06:57 AM
folow the step:
1)delete all thing except terrain and direction light
2)drag GvrMainViewer.prefab
3)create new camera name it maincamera
4)add character controll and vr look walk on maincamera
5)than drag maincamera in to vr camera
play now
Still no difference :( the simple$$anonymous$$ove function isn't firing for some reason
you have to drag just GvrVieqwer$$anonymous$$ain.prefab
not Gvr$$anonymous$$ain and not need of head in his child
and in vr camera assign maincamera after complete above step
and assign character controller on maincamera and vr look walk script is also on main camera and than in public vr camera drag the main camera
Here is a screenshot of the prefabs in the folder i just realised that i have to use the legacy folder "Gvr$$anonymous$$ain" since when i want to use the GvrViewer$$anonymous$$ain or GvrController$$anonymous$$ain it just seems to be an empty object like the first two links i just posted.
accept the answer if it solved your problem, vr mode is on than only your main camera move with your head movement
Answer by walidabazo · Sep 22, 2017 at 11:19 AM
Show this videos
https://youtu.be/9pf8CeN5SvA?list=PLazvcyckcBwjSxqwlSr6c2l8FEK-vxSV8
https://youtu.be/559WxKPYdRo?list=PLazvcyckcBwjSxqwlSr6c2l8FEK-vxSV8
Your answer
![](https://koobas.hobune.stream/wayback/20220612094805im_/https://answers.unity.com/themes/thub/images/avi.jpg)