I am making the game in which i am moving the player with trackpad but i also want to implement jump on character controller using trigger of VR Controller, can anyone help me with this. Thanks
If you use the “SteamVR Plugin”, it includes openvr and SteamVR Input, where you create controller bindings (with menu Window->SteamVR Input), then you add .json files for all controllers you want to support to Assets\StreamingAssets\SteamVR.
Code can look like this when all config is done (using Valve.VR):
bool bTrigger = false;
try
{
bTrigger = (SteamVR_Actions.default_Throttle.GetAxis(SteamVR_Input_Sources.Any) > 0.5f) ||
SteamVR_Actions.default_Fire.GetState(SteamVR_Input_Sources.Any);
}
catch { }
default_Throttle defined as a one axis input - bound to the trigger.
default_Fire defined as a button input - bound to for example the X button.
If you want to use OpenXR, you can just use UnityEngine.XR:
Code can look like this:
UnityEngine.XR.InputDevice handRDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
UnityEngine.XR.InputDevice handLDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
handRDevice.TryGetFeatureValue(UnityEngine.XR.CommonUsages.trigger, out float triggerR);
But I’m unsure, maybe OpenXR defines other way to do input. OpenXR is just about now ready for real use.
can you please show the varaibles declared because code is not working for me. i have done the changes in binding too