Forum Discussion
Anonymous
11 years agoDetecting Rift when using Playmaker?
Hi!
I'm trying to build an FSM in Playmaker to get my game to detect if the Rift is plugged in when I start it up, and then automatically switch from the OVRPlayerController to a standard camera/controller setup if the player does not have a Rift connected. I think "OVRDevice.IsHMDPresent()" is what I'm looking for but I'm such a newb that I don't know how to get that into Playmaker.
Thanks for any help!
I'm trying to build an FSM in Playmaker to get my game to detect if the Rift is plugged in when I start it up, and then automatically switch from the OVRPlayerController to a standard camera/controller setup if the player does not have a Rift connected. I think "OVRDevice.IsHMDPresent()" is what I'm looking for but I'm such a newb that I don't know how to get that into Playmaker.
Thanks for any help!
8 Replies
Replies have been turned off for this discussion
- saviorntProtegeLet me know if you find an answer to that :)
- AnonymousSomehow I figured it out by combining the advice in these two threads:
viewtopic.php?f=37&t=1648
http://hutonggames.com/playmakerforum/index.php?topic=1143.0
It only took a few lines of code, and I don't quite understand how/why it works, but now my game automagically chooses the right camera/controller combo! :mrgreen: - AnonymousHere is what I've got, in case anyone needs it or can improve upon it.
1. I created an empty game object and called it VR Detector.
2. I added the OVRDevice script from the SDK to it, along with a .cs script called Rift Detector, which I made based on the help in the threads above. Here is the content of that:using UnityEngine;
using System.Collections;
public class RiftDetector : MonoBehaviour {
public bool RiftAttached = false;
public PlayMakerFSM theFsm;
// Use this for initialization
void Start () {
if (OVRDevice.SensorCount == 0)
{
RiftAttached = false;
}
if (OVRDevice.SensorCount > 0)
{
RiftAttached = true;
}
theFsm.FsmVariables.GetFsmBool("RiftPresent").Value = RiftAttached;
}
// Update is called once per frame
void Update () {
}
}
3. Created a Playmaker FSM that does a Bool Test against the variable RiftPresent. If Yes, it creates an OVRPlayerController game object and finishes. If No, it creates a standard First Person Controller and finishes.
This is really just intended as a starting point. The idea is to have an easier way to simultaneously develop and test in VR and for standard displays. I should be able to go forward now in Playmaker without having to muck about with too much more code. :lol: - StereomikeHonored GuestGreat!
Thanks for figuring that out (and actually getting back to us, often people just leave the question open) - AnonymousThis is the part that gave me the most trouble:
theFsm.FsmVariables.GetFsmBool("RiftPresent").Value = RiftAttached;
I kept trying to figure out which Playmaker Get action would make the FSM pull the value from the script. It turns out instead that the script sends the value to the FSM. At least I think that's what happens. :? - cyberealityGrand ChampionThanks for sharing this code.
- odigamesHonored GuestThanks for this share! I can use that :)
- AnonymousI forgot to mention one step. The Rift Detector script will have an empty field in the Inspector called "The Fsm" where you have to select the FSM in order for it to connect together. I'd expect there is a way to eliminate this step by declaring it directly in the script, but I couldn't get it to work.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 1 year agoAnonymous