Menu

Documentation

Haptics for mobile and AR

Check our documentation about Haptics for mobile and AR.

Introduction

Interhaptics Mobile is designed to integrate Haptics for IOS and Android. Three scripts are used for this purpose : MobileHapticsStiffness, MobileHapticsTexture and MobileHapticsVibration. These scripts represent a Handler for each perception.

Implementation

MobileHapticsStiffness, MobileHapticsTexture, and MobileHapticsVibration are inherited from the same abstract class AMobileHapticsReader, the way to use them remains the same for each.



  •  Add them to a GameObject
  • Add preloaded material (materials that are loaded on Awake) into the array shown on the inspector.
  • Call one of the public Play functions contained in the concerned haptics perception handler (MobileHapticsStiffness, MobileHapticsTexture, or MobileHapticsVibration).

Note 1: The public play functions common parameter for each is the index. This index represents the index of the material from the loaded materials List.

Note 2: 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).


Important: The loaded materials List is different than 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.


Note 3: If you want to retrieve the index of material from your perception handler’s loaded materials List, you can use the public function.

public bool GetIndexFromTextAsset(TextAsset material, out int index)

Note 4: You can add each perception handler on the same GameObject.

Note 5: You can’t add multiple handlers of the same perception on the same GameObject.



How to use

Here the sample scene located in the MobileHaptics package. It contains three points of interaction. A button plays a vibration on click, a texture slider plays a texture on drag and a stiffness slider plays the stiffness on interaction.

Note: Stiffness is only working on IOS





1- MobileHapticsVibration


On the GameObject Handler, a MobileHapticsVibration handler is added. A material that contains a vibration perception is assigned to its array of preloaded materials.

MobileHapticsVibration contains one public method:

  • public void PlayVibration(int index): Play the vibration perception of the material.

To call the vibration when the button is clicked, we have to call the function PlayVibration(0), because we only have one material set on the MobileHapticsVibration Handler.






2 - MobileHapticsTexture


On the GameObject Handler, a MobileHapticsTexture handler is added. A material that contains a texture perception is assigned to its array of preloaded materials.

MobileHapticsVibration contains two public methods :

  •  public void PlayTexture(int index, float distance): Play the texture perception of a material based on its length.
  • public void PlayTexture01(int index, float distance01): Play the texture perception of a material based on its normalized distance (between 0 and 1).

To call the texture when the slider value changed, we have to call the function PlayTexture01(0, sliderValue) in the case of the slider value is clamped between 0 and 1. That allows us to play the whole texture from its beginning (0) to its end (1).

For this purpose, an example script is located in the package: TextureSlider.




This script requires a Slider script.


It takes two parameters:

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

3-MobileHapticsStiffness


 





Important: only working on IOS

On the GameObject Handler, a MobileHapticsStiffness handler is added. A material that contains a stiffness perception is assigned to its array of preloaded materials.

MobileHapticsVibration contains one public method:

  • public void PlayStiffness(int index, float distance): Play the texture perception of a material based on its length.

Note 1: The stiffness perception length is always clamped between 0 and 1.

To call the stiffness when the user is interacting with the slider, we have to call the function PlayStiffness(0, sliderValue) on the update, using the slider value clamped between 0 and 1.

For this purpose, an example script is located in the package: StiffnessSlider.




This script requires a Slider script.

It takes two parameters:

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

Partnership Form

Tell us more about yourself and your organization, and identify ways in which your partnership with us would yield high-impact results.


Successfully submitted. Thank you!


We will do our best to respond to you promptly.

or register directly. It's quick!




This website uses cookies to enhance your experience.
By proceeding to browse this website, you agree to our privacy & cookies policy.


Got it!