Question by
Bentoon · Apr 25, 2016 at 03:01 AM ·
vrinputmanagersamsung
Mapping Input with GearVR
I have a script applied to camera (OVRCameraRig) that works in game to move Forward, Back, Up & Down, but Not in the GEAR VR...
Can this be solved simply by playing with my OVR Input settings :
Here's Code:
public float speed = 1.0f;
// public bool startedMoving = true;
public GameObject myCam;
// Update is called once per frame
void Update () {
bool moveForward = Input.GetKey (KeyCode.W) || Input.GetKey (KeyCode.UpArrow);
bool moveLeft = Input.GetKey (KeyCode.A) || Input.GetKey (KeyCode.LeftArrow);
bool moveRight = Input.GetKey (KeyCode.D) || Input.GetKey (KeyCode.RightArrow);
#if UNITY_ANDROID
if (GearVRInput.GetAxisY > 0.1f) {
moveRight = true;
}
if (GearVRInput.GetAxisY < -0.1f) {
moveLeft = true;
}
#endif
bool moveBack = Input.GetKey (KeyCode.S) || Input.GetKey (KeyCode.DownArrow);
#if UNITY_ANDROID
if (GearVRInput.GetAxisX > 0.1f) {
moveForward = true;
}
if (GearVRInput.GetAxisX < -0.1f) {
moveBack = true;
}
#endif
if (moveForward) {
transform.position += myCam.transform.forward * speed * Time.deltaTime;
}
if (moveLeft) {
transform.position += myCam.transform.up * speed * Time.deltaTime;
}
if (moveRight) {
transform.position += myCam.transform.up* - speed * Time.deltaTime;
}
if (moveBack) {
transform.position += myCam.transform.forward * - speed * Time.deltaTime;
}
}
}
Thanks!
~be
screen-shot-2016-04-24-at-105336-pm.png
(92.9 kB)
Comment