Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Using the real Daydream Controller with Unity

Discussion in 'Daydream' started by agilelensalex, Nov 12, 2016.

  1. agilelensalex

    agilelensalex

    Joined:
    Apr 7, 2014
    Posts:
    24
    So I was hoping that now that I have a real Daydream headset, that I'd be able to use the real controller within Unity (instead of a phone with the emulator app). I paired the controller via Bluetooth... but not sure what I could do beyond that. Anyone know if this is possible yet?
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    AFAIK, this is not possible at this time.
     
  3. agilelensalex

    agilelensalex

    Joined:
    Apr 7, 2014
    Posts:
    24
    Thanks for the info.
     
  4. harperAtustwo

    harperAtustwo

    Joined:
    Nov 15, 2016
    Posts:
    25
    What technique are people using at the moment to test interactions? Are you building to the device to test the real controller? Are you using an emulator on another phone to use the controller features in Unity?
     
  5. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
    To test in the editor, it's pretty straightforward to simply hookup your own instance of a Quaternion that pretends to be GvrController.orientation, but which is driven by the mouse or keyboard. Then your code just becomes something like:

    Code (CSharp):
    1. private Quaternion _manualAimOrientation;
    2.  
    3. #if !UNITY_ANDROID || UNITY_EDITOR
    4. private void AdjustManualOrientation(float xDegrees, float yDegrees, float zDegrees)
    5. {
    6.     Vector3 eulers = _manualAimOrientation.eulerAngles;
    7.     eulers.x += xDegrees;
    8.     eulers.y += yDegrees;
    9.     eulers.z += zDegrees;
    10.     _manualAimOrientation.eulerAngles = eulers;
    11. }
    12.  
    13. void Update()
    14. {
    15.     // Modify _manualAimOrientation with mouse or keyboard, would really use Input axes probably...
    16.     const float manualAimSpeed = 20.0f;
    17.     if (Input.GetKey(KeyCode.LeftArrow))
    18.     {
    19.         AdjustManualOrientation(0.0f, -manualAimSpeed * Time.deltaTime, 0.0f);
    20.     }
    21.     if (Input.GetKey(KeyCode.RightArrow))
    22.     {
    23.         AdjustManualOrientation(0.0f, manualAimSpeed * Time.deltaTime, 0.0f);
    24.     }
    25.     if (Input.GetKey(KeyCode.UpArrow))
    26.     {
    27.         AdjustManualOrientation(-manualAimSpeed * Time.deltaTime, 0.0f, 0.0f);
    28.     }
    29.     if (Input.GetKey(KeyCode.DownArrow))
    30.     {
    31.         AdjustManualOrientation(manualAimSpeed * Time.deltaTime, 0.0f, 0.0f);
    32.     }
    33. }
    34. #endif
    35.  
    36. // Later, wherever you were using the controller orientation...
    37. #if !UNITY_ANDROID || UNITY_EDITOR
    38.     Vector3 dir = _manualAimOrientation * Vector3.forward;
    39. #else
    40.     Vector3 dir = GvrController.Orientation * Vector3.forward;
    41. #endif
    42.     dir = _camera.transform.TransformDirection(dir);
    43.  
     
    Last edited: Nov 20, 2016
  6. Nodrap

    Nodrap

    Joined:
    Nov 4, 2011
    Posts:
    83
    Wow, this is really disappointing. Was looking forward to better testing when I get a real controller. Having to plug in the controller phone, then unplug the controller phone to install to my phone, then unplug the phone to test, and then plug in the controller to test again on the PC!!! I'm really worried I'm gonna break one of the ports on the devices with all this swapping around!

    It's tricky enough testing with the emulated controller as it is and not being able to test with the real controller will really slow down the development cycle. The emulator is rubbish at emulating the touchpad clicks (double tap!) and if its all tethered you can't really test any gesture recognition.

    A big request to make the controller work with PC's and Unity please!
     
    zeb33 likes this.