Hello everybody,
I can’t seem to be able to get the camera moving inside my Gear VR App.
Inside the desktop environment mouse and keyboard input seem to be working fine. I’m using Unity 5.2.2f1 on an S6 Edge, have downloaded and extracted the oculus mobile sdk and have android studio working. On Android, I use a bluetooth keyboard.
I’ve tried these approaches so far:
- mouse input button 0 for the touchpad
- mouse axis for the touchpad
- keyboard entry wasd and arrow keys
- tried to use Oculus Utilities instead
Any ideas?
My latest collection of attempts looks like this:
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour {
public int button = 0;
public float clickSize = 50; // this might be too small
Vector3 pos; // Use this for initialization
void Start () {
OVRTouchpad.Create();
OVRTouchpad.TouchHandler += HandleTouchHandler;
}
void HandleTouchHandler(object sender, System.EventArgs e)
{
OVRTouchpad.TouchArgs touchArgs = (OVRTouchpad.TouchArgs)e;
if (touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap)
{
//TODO: Insert code here to handle a single tap. Note that there are other TouchTypes you can check for like directional swipes, but double tap is not currently implemented I believe.
/*if (Camera.current != null)
{
// pos = Input.mousePosition;
float moveForward = 0.001f;// Input.GetAxis("Mouse X");
float moveUpward = 0.0f;// Input.GetAxis("Mouse Y");
Vector3 camVec = Camera.current.transform.TransformVector(new Vector3(0.0f, moveUpward, moveForward));
Camera.current.transform.Translate(camVec);
}*/
transform.Translate(new Vector3(0, 0, 3.5f * Time.deltaTime));
}
}
void ClickHappened()
{
Debug.Log("CLICK!");
}
// Update is called once per frame
void Update () {
var speed = 3.5f;
/*if (Input.GetMouseButtonDown(button))
{
if (Camera.current != null)
{
// pos = Input.mousePosition;
float moveForward = 0.001f;// Input.GetAxis("Mouse X");
float moveUpward = 0.0f;// Input.GetAxis("Mouse Y");
Vector3 camVec = Camera.current.transform.TransformVector(new Vector3(0.0f, moveUpward, moveForward));
Camera.current.transform.Translate(camVec);
}
}*/
if (Input.GetKey(KeyCode.RightArrow))
{
transform.Translate(new Vector3(speed * Time.deltaTime, 0, 0));
}
if (Input.GetKey(KeyCode.LeftArrow))
{
transform.Translate(new Vector3(-speed * Time.deltaTime, 0, 0));
}
if (Input.GetKey(KeyCode.DownArrow))
{
transform.Translate(new Vector3(0, 0, -speed * Time.deltaTime));
}
if (Input.GetKey(KeyCode.UpArrow))
{
transform.Translate(new Vector3(0, 0, speed * Time.deltaTime));
}
if (Input.GetMouseButtonUp(button))
{
}
}
}