0
\$\begingroup\$

Here is a screenshot of the Input Manager for my project:

enter image description here

The 9th and 10th axis refer to Axis1D.PrimaryIndexTrigger (Squeeze) and Axis1D.SecondaryIndexTrigger (Squeeze) respectively, as documented on this page.

However, Input.GetAxis(trigger) always returns 0, even when

  1. the trigger name is correct, and
  2. I am squeezing the corresponding trigger really hard.

While running the debugger, I used my right Oculus controller to interact with objects in my scene. Here is the debug window:

enter image description here

Even though I was squeezing the corresponding trigger on my right Oculus controller, Input.GetAxis(trigger) still returned 0, thus causing my method to return early.

Here are the fields and properties of my Hand class, in which I am invoking the Input.GetAxis(trigger) method:

public enum XRHandControllerNode
{
    Left,
    Right
}

private XRNode trackedXRNode =>
    this.TrackedXRNode == XRHandControllerNode.Left ? XRNode.LeftHand : XRNode.RightHand;

private const float MinimumSqueeze = 0.8f;
private string trigger =>
                   this.TrackedXRNode == XRHandControllerNode.Left ?
                   "LeftIndexTrigger" :
                   "RightIndexTrigger";

public XRHandControllerNode TrackedXRNode;

Why does Input.GetAxis always return 0, and what changes should I make to ensure that any squeeze of the trigger will be correctly detected?

\$\endgroup\$
1
\$\begingroup\$

It was a timing issue. Input.GetAxis(trigger) returned values that are negligibly close to 1 in subsequent invocations of Update() as I continued squeezing the corresponding trigger on my Oculus controller.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy