Skip to main content
Up and Coming
February 27, 2013

Unity 3d SDK feedback

Decided to start a thread to post feedback on and discuss the Unity3d SDK. So far so good and it's very easy to import and use :)

I've made one small tweak to the default camera script that I found very useful so maybe it's something you'd want to include in the SDK by default? It's a simple swap between absolute headset rotation and being offset by the parent object. This way you can put the OVRCameraController into another container and still look around relative to that container, for example when inside the cockpit of a spaceship.

OVRCamera.cs

New property:

// Set to true if you want the camera rotation offset by parent rotation, useful when putting the user inside a vehicle
public bool OffsetByParent = false;


And a change inside the SetCameraOrientation method:

// Update camera rotation
if (this.OffsetByParent == true)
{
gameObject.camera.transform.rotation = gameObject.transform.parent.transform.rotation * q;
}
else
{
gameObject.camera.transform.rotation = q;
}
    This topic has been closed for replies.

    13 replies

    Inspiring
    February 27, 2013
    Yeah, this is totally something we'd be interested in doing for a future release.

    The SDK is still a work in progress, and this is one of the things we are hoping to update for the final release.
    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
    SiggiGAuthor
    Up and Coming
    February 28, 2013
    Yeah I totally understand, and in fact I was surprised by how nice things are already.

    Another idea would be do draw a Gizmo in the Unity editor to show where the actual cameras end up, this makes positioning much easier.

    Btw. my code above doesn't adjust the neck model, so things shift when doing a 180° ;)
    CCP Games, EVE: Valkyrie developer | @SiggiGG
    SiggiGAuthor
    Up and Coming
    March 4, 2013
    Another wishlist item: A simple static method to check if an Oculus Rift device is connected or not.

    The current Unity integration relies on the OVRRift.cs script being in the scene so its Awake() method is called, but we want to spawn different camera prefabs based on the Oculus being connected or not.

    Edit: Would it be possible to separate the plugin wrapper into it's own class that is used by the mono behavior?
    CCP Games, EVE: Valkyrie developer | @SiggiGG
    Inspiring
    March 4, 2013
    Currently the OVRPlayerController prefab takes care of initializing the Rift. It has the script OVRRift.cs attached to it.

    If a Rift is not available, the static function bool OVRRift.Inited() will return false. This can be checked in a separate initialization script (make sure to check within Start, since initialization is done in Awake).

    If OVRRift.Inited() returns false, then you might want to either turn off the instanced OVRPlayerController or modify it by adding another non-stereoscopic camera to it.

    We may be able to refactor this a bit, so the camera is not tied to the player controller, but that's how to works now.

    Hope that helps.
    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
    SiggiGAuthor
    Up and Coming
    March 4, 2013
    Thanks for the reply :)

    I had cases where the Inited() method was returning true even though the HMD was disconnected. Maybe the editor was keeping the static members alive or something, but I'll do more testing to figure it out. If that is the case then it's fine, people having a Rift and disconnecting it during game development or execution is an edge case after all.

    The idea you bring up is a nice compromise and I prefer that to the refactoring I've already started. I don't want to deviate too much from the standard SDK assets :)
    CCP Games, EVE: Valkyrie developer | @SiggiGG
    SiggiGAuthor
    Up and Coming
    March 5, 2013
    Hey Andres,

    I've done multiple tests now and with the Rift disconnected both from power and USB and the OVRRift.Inited() method always returns true. I have shut down Unity after disconnecting to be sure.

    Is this a defect or something I might be missing?

    Edit: Shortly after posting this it started reporting false and continues to do so even after the Rift has been connected. Is this value cached somewhere?
    CCP Games, EVE: Valkyrie developer | @SiggiGG
    Inspiring
    March 5, 2013
    Thanks for pointing this out. It seems that the "OVRRift.Inited()" function is not working as expected. We will get someone on this and try to fix it for an upcoming release.

    What we are probably going to do is create another static function, like "OVRRift.Exists()" that will return whether the Rift is detected or not so you can branch to different paths in your application.

    - Andres
    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
    SiggiGAuthor
    Up and Coming
    March 6, 2013
    Thanks Andres, that would be great :)
    CCP Games, EVE: Valkyrie developer | @SiggiGG
    SiggiGAuthor
    Up and Coming
    March 22, 2013
    Using SDK 0.1.4. Method OVRDevice.IsHMDPresent() still returns true with Rift disconnected.

    Here's the hacky way I've been using:

    /// <summary>
    /// Returns true if a Rift device is connected
    /// </summary>
    public static bool Exists()
    {
    float w = 0, x = 0, y = 0, z = 0;
    Quaternion q = Quaternion.identity;

    OVRSensorsGetOrientation(0, ref w, ref x, ref y, ref z);
    q.w = w;
    q.x = -x;
    q.y = -y;
    q.z = z;

    return q.Equals(new Quaternion(0,0,0,0)) == false;
    }
    CCP Games, EVE: Valkyrie developer | @SiggiGG
    SiggiGAuthor
    Up and Coming
    March 25, 2013
    I've tried multiple ways to use the OVRDevice.IsHMDPresent() method, but it's always returning true even when the Rift is not connected. I've messed with the order when I trigger the call and even when doing it on a keystroke it still returns true.

    Since it's very hard to get the sensor into a state where it's returning 0 or 1, I'm using this method to detect if the Rift is there or not. The plugin returns orientation 0,0,0,1 if the Rift is disconnected.

    /// <summary>
    /// Returns true if a Rift device is connected
    /// </summary>
    public static bool Exists()
    {
    Quaternion q = Quaternion.identity;
    if (OVRDevice.GetOrientation(ref q) == true)
    {
    return q.Equals(new Quaternion(0,0,0,1)) == false;
    }
    else
    {
    return false;
    }
    }
    CCP Games, EVE: Valkyrie developer | @SiggiGG