playMaker

Author Topic: Detect Oculus Rift hardware?  (Read 1523 times)

whelly

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Detect Oculus Rift hardware?
« 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, 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!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2508
  • Mender of the past
    • View Profile
    • Cleverous
Re: Detect Oculus Rift hardware?
« Reply #1 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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

whelly

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: Detect Oculus Rift hardware?
« Reply #2 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.

whelly

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: Detect Oculus Rift hardware?
« Reply #3 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.