Hi! I’m making my first VR prototype. It’s just a first person dynamic crosshair test. As the newbie I am, I made it all work… on PC, using a mouse to control the view, without any VR integration at the beginning. The question would be: is there any “easy” way to just turn the values I get with Input.GetAxis (“Mouse X”) or (“Mouse Y”) into the head tracking values used for VR? I’ve found that there are some scripts which allow you to easily implement VR camera, input, interactive objects, etc. if you use them from the start. But now that everything is almost ready, I wonder if there’s an equivalent function to Input.GetAxis for VR tracking.
This is the (ultra basic) script I use to move the camera with the mouse:
using UnityEngine;
using System.Collections;
public class CamMovement : MonoBehaviour
{
public float speedH = 2.0f;
public float speedV = 2.0f;
private float yaw = 0.0f;
private float pitch = 0.0f;
void Update ()
{
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
}
And this is another thing I’m doing on another script: filling a bar following the vertical mouse movement under specific circumstances:
void Fill ()
{
if (
(Input.GetAxis ("Mouse X") < horMargin) &&
(Input.GetAxis ("Mouse X") > -horMargin))
{
filler += fillRate * Input.GetAxis ("Mouse Y");
filler = Mathf.Clamp (filler, -10, 0);
}
}
}
Any possible way to make this all VR tracking-ready without loads of adapting work? Thank you very much.