Interhaptics Interhaptics
  • Tech 
    • Haptic Composer 
    • Interhaptics Engine & SDK 
    • How Interhaptics works 
    • Haptics 
  • Devkit 
  • Ecosystem 
  • Company 
  • Documentation 
  • Contact 
  • Blog 
  • Discord 
Download
Interhaptics Interhaptics
Download
Interhaptics
  • Tech 
    • Haptic Composer 
    • Interhaptics Engine & SDK 
    • How Interhaptics works 
    • Haptics 
  • Devkit 
  • Ecosystem 
  • Company 
  • Documentation 
  • Contact 
  • Blog 
  • Discord 

Interhaptics Unity SDK

  • folder icon closed folder iconGetting Started with Unity SDK
  • folder icon closed folder iconHow haps Renders On Each Device
  • folder icon closed folder iconInterhaptics Mobile SDK (legacy)
  • folder icon closed folder iconInterhaptics XR SDK
  • folder icon closed folder iconTroubleshooting
  • folder icon closed folder iconInterhaptics Mobile SDK
loading
Popular Searches:
  • Haptic Composer
  1. Home
  2. Interhaptics Unity SDK
  3. Interhaptics Mobile SDK (legacy)
Updated on March 17, 2023

Docy

Interhaptics Unity SDK

  • folder icon closed folder open iconGetting Started with Unity SDK
  • folder icon closed folder open iconHow haps Renders On Each Device
  • folder icon closed folder open iconInterhaptics Mobile SDK (legacy)
  • folder icon closed folder open iconInterhaptics XR SDK
  • folder icon closed folder open iconTroubleshooting
  • folder icon closed folder open iconInterhaptics Mobile SDK

Interhaptics Mobile SDK (legacy)

Estimated reading: 4 minutes 453 views

Interhaptics Mobile SDK (legacy) is an integration tool for Haptics on IOS and Android. It utilizes three scripts: MobileHapticsStiffness, MobileHapticsTexture, and MobileHapticsVibration, which handle different haptic perceptions.
To set up correctly the project, verify that Project Settings -> Player -> Other Settings -> Scripting Backend is set to IL2CPP.

Interhaptics SDK Project Settings

Before adding these scripts to a GameObject, create an empty GameObject for the HapticManager, which can be set to be persistent if desired.

All three scripts are inherited from the abstract class AMobileHapticsReader, and the implementation of each script is the same. To use them, follow these steps:

  1. Add the script to a GameObject.
  2. Add preloaded materials to the array on the inspector.
  3. Call one of the public Play functions (PlayStiffness, PlayTexture, or PlayVibration) contained in the corresponding haptic perception handler (MobileHapticsStiffness, MobileHapticsTexture, or MobileHapticsVibration) and pass the index of the material as a parameter.

Note:

 

  • If you want to add materials at runtime, you have to create a class that inherits from AMobileHapticsReader and call the protected function AddMaterial(TextAsset material).
  • The loaded materials list is different from the preloaded materials array (that you can see on the inspector). If you modified the materials loading process, the index can be different than the index of the preloaded materials array, otherwise, it remains the same.
  • You can use the public function GetIndexFromTextAsset(TextAsset material, out int index) to retrieve the index of material from your perception handler’s loaded materials List.
  • You can add each perception handler on the same GameObject.
  • You can’t add multiple handlers of the same perception on the same GameObject.
  • The sample scene located in the MobileHaptics package includes three points of interaction – a button that plays a vibration on click, a textured slider that plays a texture on drag, and a stiffness slider that plays stiffness on interaction.
  • Note: Stiffness is only supported on IOS.

1- MobileHapticsVibration

To use the MobileHapticsVibration script, add it to a GameObject and assign a material that contains a vibration perception to its array of preloaded materials. The MobileHapticsVibration script contains one public method:

  • public void PlayVibration(int index): This method plays the vibration perception of the material, the index of the material is passed as a parameter.

To call the vibration when the button is clicked, call the function PlayVibration(0) if only one material is set on the MobileHapticsVibration handler.

2 – MobileHapticsTexture

To use the MobileHapticsTexture script, add it to a GameObject and assign a material that contains a texture perception to its array of preloaded materials. The MobileHapticsTexture script contains two public methods:

  • public void PlayTexture(int index, float distance): This method plays the texture perception of a material based on its length, the index of the material and the distance are passed as parameters.
  • public void PlayTexture01(int index, float distance01): This method plays the texture perception of a material based on its normalized distance (between 0 and 1), the index of the material and the normalized distance are passed as parameters.

To call the texture when the slider value changes, call the function PlayTexture01(0, sliderValue) in the case that the slider value is clamped between 0 and 1, that allows you to play the whole texture from its beginning (0) to its end (1). An example script, TextureSlider, is located in the package and it requires a Slider script. It takes two parameters:

  • The index of the material to play.
  • The MobileHapticsTexture handler.

3-MobileHapticsStiffness

Please note that this feature is only available on IOS devices.

MobileHapticsStiffness contains one public method:

  • public void PlayStiffness(int index, float distance): This method plays the stiffness perception of a material based on its length, the index of the material and the distance are passed as parameters.

Note that the stiffness perception length is always clamped between 0 and 1. To call the stiffness when the user interacts with the slider, call the function PlayStiffness(0, sliderValue) on the update method, using the slider value clamped between 0 and 1.

 

 

An example script, StiffnessSlider, is located in the package and it requires a Slider script. It takes two parameters:

  • The index of the material to play.
  • The MobileHapticsStiffness handler.

Still stuck? Come to our Discord and we will help you out!

Leaf Illustration

Interhaptics. Copyright © 2022 Go Touch VR SAS. All rights reserved.