____________________________________________________________
Myriad Limitations:
There are a couple of very good reasons why we can't just use the mouse the normal Unity way.
- Oculus won't display the windows mouse-cursor
- You can't hijack/alter the windows mouse-cursor at-all easily
- The windows mouse-cursor aims wrong through the Oculus distortion -even if you can see it-
- Oculus ALSO doesn't display Unity GUI, which only responds to windows-mouse anyway. (suggest 3d menu objects as well)
____________________________________________________________
A Unity-Object 3D Pointer
That's right. We're gonna take a Unity asset and turn it into our pointer with a few simple scripting tricks. We'll start with your player-camera and your pointer. I use a red sphere-object as default but you can use whatever works for you.
The Script
- Create your object
- Parent object under Right Eye Anchor
- this means it'll stick to the front of the head when you move
- Transform thusly
- It should look something like this with the pointer selected
- Finally, add this script that will link the pointer-movement to your physical mouse movement.
- This responds like MouseLook and doesn't need the windows-mouse
____________________________________________________________
For Copying
using UnityEngine;
using System.Collections;
public class Pointer_Mock : MonoBehaviour {
public GameObject targetCam;
// Use this for initialization
void Start () {
targetCam = transform.parent.gameObject;
}
void Update() {
transform.LookAt (targetCam.transform);
float localX = transform.localPosition.x;
float localY = transform.localPosition.y;
float h = (localX += (Input.GetAxis("Mouse X") * 0.05f));
float v = (localY += (Input.GetAxis("Mouse Y") * 0.05f));
transform.localPosition = new Vector3 (h, v, transform.localPosition.z);
}
}
____________________________________________________________
All blog posts by UnityGirl are inspired by my work with Brunelleschi: Age of Architects on the Aesop Games team. Download the current Unity client On IndieDB
thx very much, usefull for me.
ReplyDeletecheers