Search Unity

Oculus Touch and XRController Trigger Input Actions Not Working?

Discussion in 'Input System' started by Yumby, Jun 12, 2019.

  1. Yumby

    Yumby

    Joined:
    Aug 17, 2012
    Posts:
    20
    I can't seem to get trigger input actions to work for OculusTouch Left/Right Controllers or for XRController Left/Right when using Oculus Touch Controllers. I'm surprised I can't find any mention of this anywhere in this forum. Are this working in the latest preview release?
     
    Fishing_Cactus likes this.
  2. FullMe7alJacke7

    FullMe7alJacke7

    Joined:
    Dec 17, 2013
    Posts:
    55
    I'm currently using the 0.1.2 version on 2019.1.3f1 and I am reading input but I am having trouble with it.

    So I didn't have any response from joysticks on oculus until I added the invert processor to the left and down directions (I believe the reason for this is because they will "fight" each other and remain at 0 if not set to invert one direction of the axis)
    upload_2019-6-30_9-44-18.png

    But I am getting an InvalidTypeCast here

    Code (CSharp):
    1.     private void OnMovementPerformed(InputAction.CallbackContext context)
    2.     {
    3.         Horizontal = context.ReadValue<Vector2>().x;
    4.         Vertical = context.ReadValue<Vector2>().y;
    5.     }
    But the InvalidCastError only appears when I attempt to use the right thumbstick, when I had them both on the same thumbstick they performed really strange and didn't throw an error and when I use the left thumstick it moves just fine, no errors but it only moves me between 180 degrees rotation and 0, it won't go outside of that range.

    It could be my movement code though... Still debugging but I can't find much on this either so I thought i'd contribute what I knew here.

    Code (CSharp):
    1.     private void OnMovementPerformed(InputAction.CallbackContext context)
    2.     {
    3.         Horizontal = context.ReadValue<Vector2>().x;
    4.         Vertical = context.ReadValue<Vector2>().y;
    5.     }
    6.  
    7.     private void OnOffensiveSpellCast(InputAction.CallbackContext context)
    8.     {
    9.         mps.CreateMagicBolt(mps.transform.position, mps.transform.rotation);
    10.     }
    11.  
    12.     private void OnDisable()
    13.     {
    14.         controls.Gameplay.Primary_Spell_Right.performed -= OnOffensiveSpellCast;
    15.         controls.Gameplay.Movement.performed -= OnMovementPerformed;
    16.  
    17.         controls.Disable();
    18.     }
    19.  
    20.     private void OnEnable()
    21.     {
    22.         controls.Enable();
    23.         controls.Gameplay.Movement.Enable();
    24.         controls.Gameplay.Movement.performed += OnMovementPerformed;
    25.         controls.Gameplay.Primary_Spell_Right.performed += OnOffensiveSpellCast;
    26.     }
    27.  
    28.     private void FixedUpdate()
    29.     {
    30.         if (!IsMoving) return;
    31.         transform.position += Direction * movementSpeed * Time.deltaTime;
    32.         transform.rotation = Rotation;
    33.     }
    34.  
    35.     private float Vertical { get; set; }
    36.  
    37.     private float Horizontal { get; set; }
    38.  
    39.  
    40.     private bool IsMoving => Direction != Vector3.zero;
    41.  
    42.     private Vector3 Direction => new Vector3(Horizontal, 0, Vertical);
    43.  
    44.     private Quaternion Rotation => Quaternion.LookRotation(RotationDirection);
    45.  
    46.     private Vector3 RotationDirection => Vector3.RotateTowards(
    47.         transform.forward,
    48.         Direction,
    49.         rotationSpeed * Time.deltaTime,
    50.         0);
    51. }
    Oh I also have Input in the player settings set to both atm but plan to try switching it over to just the new one for testing later