Unity Oculus OVR not responding to remove/put on headset
Asked Answered
W

4

0

I have this code:

OVRManager.HMDMounted += HandleHMDMounted;
OVRManager.HMDUnmounted += HandleHMDUnmounted;
Application.runInBackground = true;

In the Start method of a script. The callbacks are simple logging functions

void HandleHMDMounted()   { Debug.Log("ON");  }
void HandleHMDUnmounted() { Debug.Log("OFF"); }

The code does not run- I never see any logs despite putting it on/taking it off. Why?

My OVR version is 1.18.1, my Unity version is 2017.1.0f3

Waikiki answered 18/1 at 12:20 Comment(1)

>I used the public bulletScore bullet to set the reference. In the Hierarchy i have a Scoring System empty that has the Score script attached and there is a part where you can add the bulletScore scipt. But what gameObject are you dragging & dropping ? A prefab ? Something in the scene ? The real object whose OnCollisionEnter is called?

Hydrometallurgy
G
0

I have a have absolutely the same problem. Did you find a solution for this? Thanks!

Gagman answered 28/5, 2020 at 14:0 Comment(1)

So if i do this would i need to change all of the scoreBool on the bulletScore and Score scripts to _scoreBool? Im kind of new to this.

Cumbersome
A
0

Did anybody ever figure this out? I’m wondering if maybe the answer is in where we put the code?

@Waikiki @Gagman ?

Alby answered 25/6, 2021 at 4:7 Comment(1)

You won't need to change anything else.

Lynelllynelle
I
0

The reason none of these events get fired is that OVRManager must be added as a script to some GameObject.

I don’t know if this is written anywhere, I had to browse the source code to figure it out - it has Awake(), Update(), etc. functions which handle this functionality and they don’t get called unless the script is added to a GameObject.

Iddo answered 18/1 at 12:21 Comment(1)

Here is how the result went: When i started - "ScoreBool changed from False to False" When i missed - "ScoreBool changed from False to False" When i hit - "ScoreBool changed from False to True" and my "Hit" Message

Cumbersome
A
0

Try adding

using static OVRManager;

instead of OVRManager directly

Antecedence answered 18/1 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.