Skip to main content
Up and Coming
December 1, 2015

Mouse-look during development

Probably a silly question, but how do you enable mouse-look when developing GearVR apps on a PC?

I can get things working on the GearVR, but I want to test gameplay on my PC without rebuilding and installing an APK with every change I make. :D

Is there a fast way to iterate, when you don't have a DK2?
    This topic has been closed for replies.

    9 replies

    Inspiring
    December 1, 2015
    I think the current method for testing on PC is with the DK2 headset.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Inspiring
    December 2, 2015
    With the dk2 i've set up a mouse look script that will only activate when using the editor so that i dont always have to put on the headset when testing, something like this should work for gear.

    Just use something like
    #!if UNITY_EDITOR
    mouselookscript.enabled = false
    #endif
    dnhkngAuthor
    Up and Coming
    December 2, 2015
    Thanks MikeF, that looks like what I need.


    I found a script in the Standard Character assets called SimpleMouseRotator which I can add to the main camera. Which script do I add the following code to?

    #!if UNITY_EDITOR
    SimpleMouseRotator.enabled = false
    #endif



    Also, should I be using the main camera that in a new project, or should I be using the Oculus utility stuff? its hard to tell from the documentation. I am targeting the GearVR.

    -David
    Up and Coming
    December 2, 2015
    Here is a script that I wrote (mostly borrowed from the Google Cardboard SDK for Unity).

    ALT+mouse move will pitch (Y) and yaw (X)
    CTRL+mouse move will roll (Z)

    There are settings to automatically recenter both the Y & Z axis so I can still use the DK2 easily.

    If you aren't in VR mode (and don't have a DK2 plugged in) then you can drag this script directly onto your camera. But I use it with the DK2, so in that case follow these instructions:

    For Unity 5 VR: I insert a gameobject in the hierarchy between the main camera and it's parent. Then add this script to that game object.

    For Oculus VR: Drag VRMouseLook onto your OVRCameraRig (child of OVRPlayerController) and uncheckmark the "Enable Yaw" as the Oculus controller will already do that.

    HTH

    Peter
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    dnhkngAuthor
    Up and Coming
    December 2, 2015
    Tested it, and it looks great! thanks!

    Then I went over to you blog, and found great info there too :D

    Do you use the native Unity VR support or OVRCameraRig? I'm not sure I know what the difference is, but I would like to use the GearVR touchpad.
    Up and Coming
    December 2, 2015
    Great, glad that worked for you!

    For native vs OVRCameraRig I use a bit of both, depending on the app and how broken Unity is (which is getting much better lately).

    Neither has an impact on using the GearVR touchpad though:

    For the touchpad, depending on what you want to do, you can use the Oculus OVRTouchpad (in mobile SDK) if you want swipe gestures, or if you want full control then you will see the touchpad is just a standard single button mouse input, so you can directly use Input.mousePosition, Input.GetMouseButtonUp/Down(0) (or map it in the Input Manager if your input is simple).
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    Up and Coming
    December 3, 2015
    Hey @dnhkng, one caveat I should mention:

    That script does not implement a head-neck model, so it is not exactly what the user in a GearVR would see because this only pivots around the center of the game object.

    Just thought I should let you know!
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    Up and Coming
    December 27, 2015
    I've updated that original script so that it works whether you have a DK2 or not plugged in.

    I've posted it to my blog:

    http://talesfromtherift.com/unity-vr-editor-mouse-look-script/
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    Up and Coming
    December 14, 2016

    peterept said:

    I've updated that original script so that it works whether you have a DK2 or not plugged in.



    I've posted it to my blog:



    http://talesfromtherift.com/unity-vr-editor-mouse-look-script/


    The link seems to be broken.
    Virtual Reality Mini-Degree - Learn to code in Unity and build 15 VR games and experiences