Asked for help (@ Oculus) , Got sent a script. Doesn't do anything. Single sentence of instruction didn't help.
I am SIMPLY trying to MOVE an OBJECT with the OCULUS TOUCH CONTROLLERS. Using 3-axis control, Roll/Pitch?Turn,.. After a year of asking finally someone on the OCULUS site sent the following script and said as the only instruction:
"Attach to game object, select handedness, run."
It took forever to get to work, AND THEN ONLY CHANGES NUMBERS IN THE INSPECTOR!! THAT'S NOT FLYING!! :) :O ..
Here is the 'script' as posted.... and the the steps I took below:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class InputEx : MonoBehaviour {
public float TriggerVal;
public float GripVal;
public Vector2 ThumbStickVal;
public bool IsPoint;
public bool IsThumbsUp;
public enum handedness
{
None = 0,
Left =1,
Right =2,
}
public handedness Handedness;
private OVRInput.Controller m_controllerMask;
void Start()
{
if (Handedness == handedness.Left) {
m_controllerMask = OVRInput.Controller.LTouch;
}
if (Handedness == handedness.Right) {
m_controllerMask = OVRInput.Controller.RTouch;
}
}
void Update () {
AnalogInputUpdate ();
DigitalInputUpdate ();
}
void AnalogInputUpdate()
{
if (Handedness == handedness.Left) {
TriggerVal = OVRInput.Get (OVRInput.RawAxis1D.LIndexTrigger);
GripVal = OVRInput.Get (OVRInput.RawAxis1D.LHandTrigger);
ThumbStickVal = OVRInput.Get (OVRInput.Axis2D.PrimaryThumbstick);
}
else if (Handedness == handedness.Right) {
TriggerVal = OVRInput.Get (OVRInput.RawAxis1D.RIndexTrigger);
GripVal = OVRInput.Get (OVRInput.RawAxis1D.RHandTrigger);
ThumbStickVal = OVRInput.Get (OVRInput.Axis2D.SecondaryThumbstick);
}
}
void DigitalInputUpdate()
{
//capacitive point and thumbs up
IsPoint = !(OVRInput.Get (OVRInput.Touch.PrimaryIndexTrigger, m_controllerMask));
IsThumbsUp = !OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, m_controllerMask);
//digital buttons down
if (OVRInput.GetDown (OVRInput.RawButton.X , m_controllerMask)) {
Debug.Log ("X Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.Y , m_controllerMask)) {
Debug.Log ("Y Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.A , m_controllerMask)) {
Debug.Log ("A Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.B , m_controllerMask)) {
Debug.Log ("B Down");
}
if (OVRInput.GetDown (OVRInput.RawButton.Start , m_controllerMask)) {
Debug.Log ("Menu Button Down");
}
//digital buttons up
if (OVRInput.GetUp (OVRInput.RawButton.X , m_controllerMask)) {
Debug.Log ("X Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.Y , m_controllerMask)) {
Debug.Log ("Y Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.A , m_controllerMask)) {
Debug.Log ("A Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.B , m_controllerMask)) {
Debug.Log ("B Up");
}
if (OVRInput.GetUp (OVRInput.RawButton.Start , m_controllerMask)) {
Debug.Log ("Menu Button Up");
}
}
}
========================================================================================================================================================================
Here is what I did with this mysterious unexplained, un- 'commented' script:
1) I create a New Unity Project and import Oculus Utilities.
2) I create a cube, I drag in OVR Camera Rig make it a child of the cube..
3) I select Cube, add component New Script and paste in your text in Visual Studio. I save the file as fly.cs
4) I set player setting for VR Enabled and Oculus (No open VR)
5) I run the game window, try every single button and grips etc on each oculus controller, Nothing at all,.
So, That's where i'm at, I look at the Cube inspector, it does say at the top of the Script Component entry 'NOTHING SELECTED' (???) The CUBE IS SELECTED!! The errors I get are:
1) The referenced script on this Behaviour is missing! (referenced Script? I only have one Script and it's fly.cs ... It is Definately in the Project Folder, That where I created it, as you can see above, I addeda 'new script' the the cube, then saved it in Assets/Scripts)
2) The referenced script on this Behaviour (Game Object 'Cube') is missing!
WHAT is the 'Referenced Script'? I only HAVE one SCRIPT,.. I will attach a screen grab, of the Inspector and the Console,.
Thank you for any help.
InputEx : $$anonymous$$onoBehaviour
if your script is named fly, it needs to be
fly : $$anonymous$$onoBehaviour
Your answer
![](https://koobas.hobune.stream/wayback/20220612154524im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Checking if canvas world space is visible in CenterEyeAnchor? 0 Answers
Why does my gameObject's functionality change after exiting and reentering scene? 0 Answers
What is the best way to play with the rotation of Oculus' OVRPlayerController? 1 Answer
Unity Interactive Tutorials Scripting Problem 0 Answers
SmoothDamp in my FPS controller. Does not feel like it is working. 0 Answers