Forum Discussion
Kothe
12 years agoHonored Guest
Reset Orientation
Hi.
I have seen some post about reset the view, but I don´t understand the way they do. I not a programer.
I would like to find a simple script to triger then reset the rotation of the OWR camera controller.
The situation is this: When the OWR camera control exceeds a specific degree reset it rotation value.
Thanks in advance.
I have seen some post about reset the view, but I don´t understand the way they do. I not a programer.
I would like to find a simple script to triger then reset the rotation of the OWR camera controller.
The situation is this: When the OWR camera control exceeds a specific degree reset it rotation value.
Thanks in advance.
8 Replies
Replies have been turned off for this discussion
- vrdavebOculus StaffHere is one way to do it. Copy and paste the following code into a new C# script in your project and then attach the script to a GameObject in your scene.
using UnityEngine;
public class Reset : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.R))
OVRDevice.ResetOrientation();
}
} - vrdavebOculus StaffThe previous code would reset the orientation when you pressed "R". To reset when the player has turned farther than "MaxRotation", try this:
using UnityEngine;
public class Reset : MonoBehaviour {
public float MaxRotation = 90f;
// Update is called once per frame
void Update () {
Vector3 pos = Vector3.zero;
Quaternion rot = Quaternion.identity;
OVRDevice.GetCameraPositionOrientation(ref pos, ref rot);
if (!(rot.eulerAngles.y < MaxRotation || 360f - rot.eulerAngles.y < MaxRotation))
OVRDevice.ResetOrientation();
}
} - KotheHonored GuestBoth very useful .
THX - KotheHonored GuestHi, I find this errors on the scripts
Assets/PREFAB/RESET.cs(7,35): error CS1501: No overload for method `ResetOrientation' takes `0' arguments
Assets/PREFAB/Reset_2.cs(3,14): error CS0101: The namespace `global::' already contains a definition for `Reset'
and the.... All compiler errors must be fixed before...
What I am doing wrong ?
Thx - drashHeroic ExplorerYou might be using a version of the SDK where ResetOrientation requires a sensor #. Try changing it from ResetOrientation() to ResetOrientation(0).
- vrdavebOculus StaffIf the class name "Reset" conflicts with something else in your project, you could also rename that to "ResetCamera". You'll need to rename the script to "ResetCamera.cs".
- CubicleNinjasProtegeThank you VRDave!
Here is a modified version of the reset orientation script that resets when any key is pressed.using UnityEngine;
public class ResetAnyKey : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.anyKeyDown)
OVRDevice.ResetOrientation();
}
}
I'm using it within the 'Health and Safety Warning' display so as a user clears the warning they go into the menu facing the proper direction. The file name should be "ResetAnyKey.cs". - AnonymousThanks for the scripts!
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 months ago
- 5 years ago
- 3 years ago
- 4 years ago
- 5 years ago