Hi,
My situation: Two InputActions are used in the program: one is named “XRI Default Input Actions”, and the other is named “TankBrawlActions”. I assign TankBrawlActions to the PlayerInput component.
I obtain the corresponding (TankBrawlActions) Action through a script and use ReadValue() to read the value, but it is always (0,0).
Only when using the thumbstick in “XRI Default Input Actions” can there be a correct value. This is not the way I want. I want the two to coexist and be able to read the value of the thumbstick using “TankBrawlActions”.
When I use a single Controller, I can obtain the value corresponding to that handle. Once two Controller are used together, one of the handle values cannot be obtained.
public class AccessXRControllerValues : MonoBehaviour
{
private InputAction leftHandStickAction;
private InputAction rightHandStickAction;
private XRInputValueReader<Vector2> leftHandStickReader;
[SerializeField] private TextMeshProUGUI valuesText;
private StringBuilder sb = new StringBuilder();
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
var tmp_PlayerInput = Object.FindFirstObjectByType<PlayerInput>();
leftHandStickAction = tmp_PlayerInput.actions.FindAction("PlayerMovement");
rightHandStickAction = tmp_PlayerInput.actions.FindAction("PlayerRotation");
leftHandStickAction.Enable();
}
// Update is called once per frame
void Update()
{
if (leftHandStickAction != null)
{
sb.Append($"Left:{leftHandStickAction.ReadValue<Vector2>()}");
sb.Append("\n");
sb.Append($"Right:{rightHandStickAction.ReadValue<Vector2>()}");
valuesText.text = sb.ToString();
sb.Clear();
}
}
}
Best,
NSWells

