Forum Discussion
Woody3D
8 years agoExpert Protege
I am learning to incorporate Oculus Touch with older Input Manager apps - WITH ABSOLUTELY NO LUCK!!!
But as well as I though I understood Input manager etc. I am at a complete loss. I have of course imported the Oculus Integration package. I just want to know how to use the trigger to SHOOT, to ...
MikeF
8 years agoTrustee
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");
}
}
}
Attach to gameobject, select handedness, run.
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
- 4 months ago
- 6 months ago
- 8 months ago