Search Unity

Basic input rotation hello world

Discussion in 'AR/VR (XR) Discussion' started by dakomz, Jan 11, 2020.

  1. dakomz

    dakomz

    Joined:
    Nov 12, 2019
    Posts:
    40
    I have the following script. I set the camera transform to either a dummy object or something relevant from the OVRCameraRig hierarchy.

    I can see that the quat values are changing when I move around the controller

    But nothing on the screen.

    Goal is really just to get the basic "show a ray" stuff working, like a pointer.

    Any help is appreciated.

    Thanks!

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Controller : MonoBehaviour
    6. {
    7.     public Transform camera;
    8.  
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.        
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         var controllerType = OVRInput.IsControllerConnected(OVRInput.Controller.RTrackedRemote) ? OVRInput.Controller.RTrackedRemote : OVRInput.Controller.LTrackedRemote;
    19.  
    20.         var quat = OVRInput.GetLocalControllerRotation(controllerType);
    21.  
    22.         Vector3 fwd = quat * camera.forward;
    23.  
    24.         Debug.DrawRay (transform.position, fwd * 10, Color.red, 0f, true);
    25.         Debug.LogFormat("{0},{1},{2},{3}", quat.x, quat.y, quat.z, quat.w);
    26.     }
    27. }
    28.  
     
  2. dakomz

    dakomz

    Joined:
    Nov 12, 2019
    Posts:
    40
    whups... nm... was showing up in scene view :)