License requirement
The functionality described requires a MANUS Bodypack
or a MANUS license key
with the Unity
feature enabled.
Interaction framework
Our interaction framework is a powerful tool that allows you to easily implement interactive elements in your Unity projects. With this framework, you can create realistic hand interactions, such as picking up objects, interacting with buttons and switches, teleporting, and more. To help you get started, we provide an example scene that showcases the capabilities of the interaction framework. This scene demonstrates various interactable objects, including grabbables, switches, turnables, sliders, and buttons. By following the step-by-step instructions below, you can set up the hand and interactables in your own Unity project. Each section provides clear guidance on how to add the necessary scripts and components to achieve the desired functionality.
Setting up the hand
To enable hand interactions in your Unity project using the Unity Interaction Framework, you need to follow these steps:
-
Add the
HandGrab
script to the wrist bone of your character model. This script allows the hand to grab objects. -
For the ghost hand effect, add the
InteractionHand
script to the same object that contains theSkeleton
script. This script provides visual feedback for hand interactions. -
Optionally, you can modify the grab radius or the physics layer to customize the hand interactions.
You have now set up the hand in your Unity project and can start implementing interactive elements.
Interacting with buttons/switches
To interact with objects, you need collision. You can do this manually by adding colliders to the objects, or you can use the ColliderGenerator
script provided with the plugin. Simply add the ColliderGenerator
script to the same game object that contains the skeleton script.
Teleporting
To enable teleportation controls place the teleporter
prefab as a child of the wrist bone in your Unity project.
Setting up interactables
The Interaction Framework provides a variety of interactable objects that you can easily incorporate into your Unity projects. These objects include grabbables, switches, turnables, sliders, and buttons. This section will guide you through the process of setting up each type of interactable.
Grabbables
Grabbables are objects that can be picked up and manipulated by the player. They are typically used for objects that the player can hold or move around in the game world. To make an object grabbable, follow these steps:
-
Add the
GrabbableObject
script to the object that you want to make grabbable. This script enables the object to be grabbed by the player. -
(Optional) If you want to make the object throwable, you can also add the
ThrowableObject
script. This script allows the player to throw the object after grabbing it.
Switches
Switches are interactive objects that can be toggled between two states, such as on/off or open/closed. They are commonly used for controlling lights, doors, or other game mechanics. To set up a switch, follow these steps:
-
Add the
RockerSwitch
component to the object that represents the switch. -
Add two collision areas for both sides of the switch with colliders. These collision areas define the regions where the player can interact with the switch.
-
Set the pivot point around which the switch should rotate.
- Set the rotation amount that determines the range of motion for the switch.
Turnables
Turnables are objects that can be rotated by the player. They are often used for knobs, dials, or other objects that can be turned. To make an object turnable, follow these steps:
-
Add the
TurnableObject
component to the object that you want to be rotatable. -
Set the turn axis and the up axis. The up axis should be perpendicular to the turn axis.
- Make sure the object has a collider component.
Sliders
Sliders are interactive objects that can be moved along a linear path. They are commonly used for volume controls, settings, or other adjustable parameters. To set up a slider, follow these steps:
-
Add the
MovableObject
component to the object that you want to be movable. -
Set the start and end position of the slider. These positions define the range of motion for the slider.
- Make sure the object has a collider component.
Buttons
Buttons are interactive objects that can be pressed or released by the player. They are often used for triggering actions or events in the game. To set up a button, follow these steps:
-
Add the
PushButton
component to the button object. -
Assign the moving part of the button. This is the part that visually moves when the button is pressed.
-
Assign the two collision areas for pressing and releasing the button.
Prefabs
The Interaction Framework ships with prefabs for each type of interactable object mentioned above. You can inspect these prefabs to understand how they are set up and use them in your own projects. Simply navigate to the appropriate folder in the Unity Editor and drag the desired prefab into your scene.
By following these instructions, you can easily incorporate interactive elements into your Unity projects using our Interaction Framework.
Haptics
The interaction framework supports haptic feedback on MANUS Glove devices that support haptics. When the skeleton
object has the enable haptics
boolean enabled, colliders are added to the hand to detect collisions with interactables. When a collision is detected, the haptic feedback is triggered on the glove.
Framework haptics
The interactables come with built-in haptic feedback. Each hand will include a HandHaptics
component. When a hand interacts with an interactable, the system retrieves the HandHaptics
component and overrides the haptic feedback using the SetHapticsStrengthOverride
function, as described below. When extending the interaction framework, this method is the recommended approach for implementing haptic functionality.
/// <summary>
/// Sets the override haptics strength for a particular finger
/// Override values will be used in place of physically determined collider values unless the override value is -1
/// </summary>
/// <param name="p_FingerIndex">index of the finger to set haptics strength for</param>
/// <param name="p_Strength">Haptic strength to set, [0,1] or -1 for no override</param>
public void SetHapticsStrengthOverride( int p_FingerIndex, float p_Strength )
{
m_HapticsStrengthOverride[p_FingerIndex] = p_Strength;
}
Manual haptics
However, manual triggering of haptic feedback is also possible, either by skeleton ID or glove ID. The following code snippets outline the functions for triggering haptic feedback on a specific hand given the skeleton or glove ID. To stop the haptic feedback, the power value needs to be returned to 0
Note
It's recommended that you disable the skeleton based haptic feedback when manually triggering haptic feedback as to avoid feedback overlapping.
/// <summary>
/// Activate haptics on specific hand given the skeleton id.
/// </summary>
/// <param name="p_SkeletonId">Skeleton id</param>
/// <param name="p_HandType">Hand type to send to</param>
/// <param name="p_Powers">Strength to send to hand</param>
public void SendHapticDataForSkeleton( uint p_SkeletonId, CoreSDK.Side p_HandType, float[] p_Powers )
{
CoreSDK.SDKReturnCode t_Result = CoreSDK.VibrateFingersForSkeleton( p_SkeletonId, p_HandType, p_Powers );
if( t_Result != CoreSDK.SDKReturnCode.Success )
{
Debug.LogError( $"MANUS-ERROR: {t_Result}, could not vibrate fingers." );
return;
}
}
/// <summary>
/// Activate haptics on specific hand given the glove id.
/// </summary>
/// <param name="p_SkeletonId">Glove id</param>
/// <param name="p_Powers">Strength to send to hand</param>
public void SendHapticDataForGlove( uint p_GloveID, float[] p_Powers )
{
CoreSDK.SDKReturnCode t_Result = CoreSDK.VibrateFingersForGlove( p_GloveID, p_Powers );
if( t_Result != CoreSDK.SDKReturnCode.Success )
{
Debug.LogError( $"MANUS-ERROR: {t_Result}, could not vibrate fingers for glove." );
return;
}
}