0

I want to use the buttons to trigger actions in my Unity scene, but I cannot figure out how to call the corresponding methods, when I press the button. I use VRTK 4 (beta) and cannot find any useful documentation or answered questions to it.

Nalara
  • 101
  • 1
  • 7

1 Answers1

0

VRTK Version 4.0 Beta

  1. Look up the "Legacy Input Index" from this table for the button of your device: https://docs.unity3d.com/Manual/xr_input.html
  2. Check the corresponding feature type.
    • If it is a button, you don't need to add it the "Project Settings -> Input" list.
    • If it is an axis, you need to add it to the "Project Settings -> Input" list (by increasing the size of the list). Have a look at the other (similar) buttons and copy the scheme:

Example Left Oculus Trigger:
Name: VRTK_Axis9_LeftTrigger *[Adapt your name]*
[...] Gravity: 0
Dead: 0.001
Sensitivity: 1
[...]
Type: Joystick Axis
Axis: 9th axis (Joysticks) *[Enter the index number you've looked up before]*
Joy Num: Get Motion from all Joysticks

Look up the properties and their descriptions here: https://docs.unity3d.com/Manual/class-InputManager.html


  1. Create a new GameObject in Unity.
    • If it is a Button:
      • add the Zinnia UnityButtonAction script. Set "Joystick [index number you've looked up]" as key code.
    • If it is an 1DAxis:
      • and you want its value (float):
        • add the VRTK UnityAxis1DAction script. Set the name from the "Project Settings -> Input" (in the example "VRTK_Axis9_LeftTrigger") as axis name.
      • and you want its pressed/released (bool):
        • add the VRTK UnityAxis1DAction script. Set the name from the "Project Settings -> Input" (in the example "VRTK_Axis9_LeftTrigger") as axis name.
        • add the Zinnia FloatToBoolean script. In the "Transformed" field, reference the GameObject itself (press + to add). Choose BooleanAction.Receive.
        • add the Zinnia BooleanAction script. In the "Activated" field, reference the GameObject that shall react to the button state (press + to add) and choose the method, that shall be called, when the button is pressed. (Repeat for the "Deactivated" field with the method, that shall be called, when the button is released.)
    • If it is an 2DAxis:
      • and you want its values:
        • add the VRTK UnityAxis2DAction script. Set the names from the "Project Settings -> Input" from your x and y axes to the corresponding X axis name and Y axis name.

I hope this helps you getting started with the new VRTK version!

Nalara
  • 101
  • 1
  • 7