Physics Glove Guide for Unity
With the bHaptics Physics Glove SDK, you can give the TactGlove users an immersive VR experience with vibrations in the fingertips and wrists.
What is this for
In order to enable virtual hands to physically collide with the virtual environment and interact with virtual objects, physics can be applied to virtual hands.
The master-slave structure is commonly used to apply physics to hands. To implement this, you can use plugins such as HPTK, Ultraleap Physics Hand, Auto Hand. Or you can also create your own implementation.
bHaptics Physics Glove SDK can apply haptics to virtual hands using master-slave physics. It provides the appropriate vibrations to the haptic glove, so that users feel as if they are actually picking up a virtual object.
You don't need to use Physics Glove SDK to just vibrate TactGlove. You can still use TactGlove if you've made it as far as the previous Unity Guide.
The instructions in this document provide features to help you apply better haptics when your virtual hands perform physical actions.
Prerequisite
Specifications
- Unity: 2019.4.0+
- Hand physically implemented in a master-slave structure
- ex) Ultraleap hand, Auto Hand, HPTK
- bHaptics Plugin: 2.3.0+
- It already includes the base bHaptics SDK and bHaptics Physics Glove SDK.
Before you start
We assume that you've followed the Unity Guide to set up your Unity project.
Make sure that these requirements have been met in your Unity project.
- The haptic application is linked to your project using the API key and App ID.
- The "[bhaptics]" prefab exists in your scene.
Add Prefab
- In the project window, go to "Assets" → "Bhaptics" → "SDK2" → "Prefabs".
- Add "[bHapticsGlove]" prefab into your scene.
- In the hierarchy, select "[bHapticsGlove]" which you added, and you will see the Bhaptics Physics Glove component in the inspector.
- Select "Create New GloveHapticSettings" button. Then the glove haptics settings will appear.
These values set by default will work ideally in a typical environment. However, you may need to adjust the parameter values depending on your project environment for a good feel.
A more detailed description of the parameters can be found on the BhapticsPhysicsGloveSettings page in the Reference.
Apply bHaptics to Physics Hand
Depending on how the physics of your hands are implemented, the way you register events may vary.
However, the common principle is that when the fingertip detects a collision, the motor in the fingertip provides the appropriate amount of haptics.
Find a GameObject with a Collider(or Rigidbody) located at the figertip, then attach a component that implements the content below. When the Collision event is invoked and the function below is executed, the glove will provide haptics.
For more information on the Collision event in Unity, refer to manual from Unity.
Depending on the plugin you are using, there might be events that will be invoked when a collision event occurs. Similarly, you can do this by calling a function that applies the haptic. Refer to below.
Glove has the following motor mappings.
SendEnterHaptic
This code is a function that we created assuming that it will be used in OnCollisionEnter
.
private int fingerIndex;
private bool isLeft;
private void OnCollisionEnter(Collision collision)
{
// We typically use collision.relativeVelocity, but depending on how your hand physics are designed, you can use other overload functions.
BhapticsPhysicsGlove.Instance.SendEnterHaptic(isLeft ? PositionType.GloveL : PositionType.GloveR, fingerIndex, collision.relativeVelocity);
}
SendStayHaptic
This code is a function that we created assuming that it will be used in OnCollisionStay
.
private int fingerIndex;
private bool isLeft;
private void OnCollisionStay(Collision collision)
{
BhapticsPhysicsGlove.Instance.SendStayHaptic(isLeft ? PositionType.GloveL : PositionType.GloveR, fingerIndex, slaveTransform, masterTransform);
}
SendExitHaptic
This code is a function that we created assuming that it will be used in OnCollisionExit
.
private int fingerIndex;
private bool isLeft;
private void OnCollisionExit(Collision collision)
{
BhapticsPhysicsGlove.Instance.SendExitHaptic(isLeft ? PositionType.GloveL : PositionType.GloveR, fingerIndex);
}
Register three events and test them out. The events will fire when the fingertips make contacts.
For more information about these haptic functions, see the reference of class BhapticsPhysicsGlove.