Forum Discussion
bdeschryver
12 years agoExplorer
Reset Rift yaw when game starts
Hey Unity users,
I am building a demo of a (virtual) scene to experience while being sit on a chair with the Rift.
When my Unity software starts, the screen is all black so that no image is displayed during the time I am giving the Rift to the participant for the demo. He has time to put the Rift on his head and when he is ready, I am pressing a key and the virtual world fades in on the screen.
The problem with this is that when I start my software, it uses the Rift yaw value at that moment for the 'forward' direction of the camera. If then I pass the Rift the someone who puts it on but is not oriented as the Rift was when my software started, he will see the virtual world has he had already rotated...
I need to make sure that no matter what the current Rift yaw value is, when I press the key to start displaying my virtual world on the screen, it should be 'reset' so that the camera direction will be straight forward. This way I can press the key when the guy is looking straight in front of him and make sure he sees what I want him to see at startup.
Any idea how to do that ? I know in the Oculus demos, a key is used to reset the sensor data. In my case only the yaw is needed.
I tought InitializeInputs or SetCameras from OVRPlayerController would do that but it does not help...
Thanks !
I am building a demo of a (virtual) scene to experience while being sit on a chair with the Rift.
When my Unity software starts, the screen is all black so that no image is displayed during the time I am giving the Rift to the participant for the demo. He has time to put the Rift on his head and when he is ready, I am pressing a key and the virtual world fades in on the screen.
The problem with this is that when I start my software, it uses the Rift yaw value at that moment for the 'forward' direction of the camera. If then I pass the Rift the someone who puts it on but is not oriented as the Rift was when my software started, he will see the virtual world has he had already rotated...
I need to make sure that no matter what the current Rift yaw value is, when I press the key to start displaying my virtual world on the screen, it should be 'reset' so that the camera direction will be straight forward. This way I can press the key when the guy is looking straight in front of him and make sure he sees what I want him to see at startup.
Any idea how to do that ? I know in the Oculus demos, a key is used to reset the sensor data. In my case only the yaw is needed.
I tought InitializeInputs or SetCameras from OVRPlayerController would do that but it does not help...
Thanks !
14 Replies
Replies have been turned off for this discussion
- philedayMemberCheers, I'll give that a go this evening. Thanks for the advice.
- philedayMemberWell it worked. Well sort of. I didn't to call the create a function to call the "OVRDevice.ResetOrientation" I simple added an input getbuttondown to the OVRDevice.cs scripted. This is fine if you want to have this function be true for the whole of your game, which I did.
Below is an example of the code. The code in pink is the orginal code and the black bit is what I added. The resetyaw is a named input in the input settings so I can change the key at anypoint without changing the code. Hope this helps others.
void Update()
{
MessageList oldMsgList = MsgList;
OVR_Update(ref MsgList);
if(Input.GetButtonDown ("resetyaw")) {
OVRDevice.ResetOrientation(0);
}
// HMD SENSOR
if((MsgList.isHMDSensorAttached != 0) &&
(oldMsgList.isHMDSensorAttached == - CaliberMengskExplorerJust to let you know how to use send message. Send message calls a function, not a command. So if you want to properly use it, the script you are wanting to use it has to have a function named that, and code in it to actually run.
As for your reset, you shouldn't have to reference any scripts anyway, as the OVRDevice code is a globally functioning class. It should be as simple as checking to see if the device exists, and calling the function to reset.
For example:
if(OVRDevice.IsHMDPresent())
{
OVRDevice.ResetOrientation(0);
}
Placing that in the start works fine for me. This makes sure there is a rift plugged in. If not, then it doesn't run it. This gets rid of the object reference not set to an instance of an object error you were getting. - philedayMemberI know its been a long time since this subject was posted but I thought I would add an update. CaliberMengsk is right about the function being global but what I wasn't doing was moving the OVR directory into the standard assets folder. If it isn't in the standard assets folder the script can run after your script calling the function which means that it doesn't exist yet.
So to conclude, if you want this to work move the OVR into the standard assets folder and not have your script in the standards assets folder.
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
- 5 years ago
- 3 years ago
- 2 years ago
- 16 days ago
- 5 years ago