Fix UnityXR Haptics

This commit is contained in:
Pascal Serrarens 2023-03-14 10:54:52 +01:00
parent 6d3c7edd0d
commit aa61ffd2f4
2 changed files with 14 additions and 0 deletions

View File

@ -247,6 +247,14 @@ namespace Passer.Tracking {
renderers[i].enabled = showModel; renderers[i].enabled = showModel;
} }
public virtual void Vibrate(float length, float strength) {
if (device.TryGetHapticCapabilities(out var capabilities) &&
capabilities.supportsImpulse) {
device.SendHapticImpulse(0u, strength, length);
}
}
#endregion Init #endregion Init
#endif #endif
} }

View File

@ -139,6 +139,12 @@ namespace Passer.Humanoid {
controllerInputSide.option |= controller.option > 0; controllerInputSide.option |= controller.option > 0;
} }
public override void Vibrate(float length, float strength) {
UnityXRController unityXrController = sensorComponent as UnityXRController;
if (unityXrController != null)
unityXrController.Vibrate(length, strength);
}
// arm model for 3DOF tracking: position is calculated from rotation // arm model for 3DOF tracking: position is calculated from rotation
static public Vector3 CalculateHandPosition(HandTarget handTarget, Vector3 sensor2TargetPosition) { static public Vector3 CalculateHandPosition(HandTarget handTarget, Vector3 sensor2TargetPosition) {
Quaternion hipsYRotation = Quaternion.AngleAxis(handTarget.humanoid.hipsTarget.transform.eulerAngles.y, handTarget.humanoid.up); Quaternion hipsYRotation = Quaternion.AngleAxis(handTarget.humanoid.hipsTarget.transform.eulerAngles.y, handTarget.humanoid.up);