Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: whelly on March 11, 2015, 12:22:39 AM

Title: Detect Oculus Rift hardware?
Post by: whelly on March 11, 2015, 12:22:39 AM
I spent way too many hours on this last night to no avail. It's probably super simple, but I have no programming skills whatsoever so I come to you guys for help.

Basically I found this code on the Oculus Rift forums (https://forums.oculus.com/viewtopic.php?t=1648#p219052), and I think it's working (haven't tested it since I don't have a Rift at the moment) but I'm losing some much needed Playmaker support. Here's the script I'm using:

Code: [Select]
using UnityEngine;
using System.Collections;

public class riftdetector2 : MonoBehaviour {

public GameObject nonOVRCam;
public GameObject ovrRig;
private bool oculusActive = true;

void Update () {
if (oculusActive && !OVRManager.display.isPresent){
ovrRig.SetActive(false);
nonOVRCam.SetActive(true);
}
if (!oculusActive && OVRManager.display.isPresent){
nonOVRCam.SetActive(false);
ovrRig.SetActive(true);
}
oculusActive = OVRManager.display.isPresent;
}
}

Is there someway to turn this into a Playmaker action that works similarly to the Bool Test action? So that if there is a Rift detected it triggers a certain event, and vice versa? Again, sorry if it's a dumb question, I'm still grasping the basics of scripting, but any help would be really appreciated. Thanks!
Title: Re: Detect Oculus Rift hardware?
Post by: Lane on March 11, 2015, 07:14:45 AM
This should work if that code is still valid, I didn't test it.

Let me know.
Title: Re: Detect Oculus Rift hardware?
Post by: whelly on March 11, 2015, 10:11:35 PM
Thanks so much Lane! I'll report when I get my Rift back and test it out.
Title: Re: Detect Oculus Rift hardware?
Post by: whelly on March 21, 2015, 06:45:56 PM
I tested it and it seems to work perfectly with a DK2. Thanks again! If there's anybody with a DK1, feel free to respond if it worked for you.