WindowsMR haptics uses hardcoded strength and inappropriately large pulse duration
Environment
- Source of VRTK: Github
- Version of VRTK:: 3.3.0 (d88c9ea)
- Version of Unity3D: 2018.1.0f2
- Hardware used: Samsung Odyssey
- SDK used: WindowsMR
Steps to reproduce
- Follow instructions for setting up native WindowsMR + controller extension (NOT SteamVR)
- Add
VRTK_InteractTouchto controller alias(es) - Add
VRTK_InteractableObjectandVRTK_InteractHapticsto an object in your scene - Adjust the strength and duration for one of the sets of settings on
InteractHaptics- I usedHaptics On Touch - Build and run (because haptics only work in built applications)
- Reach a controller into the interactable object
Expected behavior
The haptics should occur at the strength and duration set in the editor.
Current behavior
The haptics always emit for 1 second at full strength.
See [SDK_WindowsMRController.cs] at line 404:
public override void HapticPulse(VRTK_ControllerReference controllerReference, float strength = 0.5F)
{
uint index = VRTK_ControllerReference.GetRealIndex(controllerReference);
WindowsMR_TrackedObject device = GetControllerByIndex(index).transform.parent.GetComponent<WindowsMR_TrackedObject>();
if (device != null)
{
device.StartHaptics(1f, 1f);
}
}
Workaround
Modify line 404 to use the passed in strength and an arbitrarily low duration:
device.StartHaptics(strength, 0.1f);
NOTE: the duration that WindowsMR_TrackedObject.StartHaptics() takes as a second paramater is not the same as the overall duration of the haptics. This is the duration of the haptic pulse and should be smaller than 1f, but I'm not sure how much smaller so I just used 0.1f.
Thanks for the workaround, turned off haptics because of this bug in my previous build!
Closing this as it's related to an older version of VRTK (v3.3) the master branch is now on VRTK v4. Feel free to request to reopen if the issue is still present.