Hapticlabs Studio directly interfaces with Unity through its TCP port, and you can also connect Unity directly to the satellite after uploading tracks to the satellite. To facilitate the setup and usage of these connections, we created a Unity package, available here.

Setup

Installation

  1. Download the Hapticlabs Unity package from https://github.com/HapticlabsIO/UnityHapticlabsController
  2. Within your Unity scene, import the downloaded folder, for example into your "Assets" folder.
  3. Within your Unity scene, drag the "Hapticlabs Manager.prefab" into your scene.
  4. Done! Now you can start configuring your connection.

Configuration

It is not recommended to change any settings of the Hapticlabs Manager except the Hapticlabs (Script) configuration.

There, you have a few options:

Use TCP

By ticking this box, Unity will connect to Hapticlabs Studio when the scene is running. This allows you to access all the tracks in your currently opened projects.

Use Serial

By ticking this box, Unity will connect to a Hapticlabs Satellite connected to your computer. This way, you can access all tracks that have been uploaded to the satellite.

If you choose to communicate this way, you need to ensure the satellite is not connected to Hapticlabs Studio because it can not connect to multiple programs at the same time.

Log Debug Infos

By ticking this box, you can enable the logs of the Hapticlabs Manager. These are primarily for debugging purposes.

Usage

Once you have the connection properly set up, you can start including haptics in your Unity project!

For that, anywhere in your project you can call the following functions:

Hapticlabs.StartTrack(string trackName, bool queue=false, float amplitudeScale=1.0f);

With this command, you can start the track with the specified track name.

  • trackName: a string containing the name of a track in the currently opened project in Hapticlabs Studio or the name of a track that has been uploaded to the satellite.
  • queue: whether to immediately play back the specified track (queue: false) or to wait for other tracks currently playing back to complete first (queue: true).
  • amplitudeScale: with this parameter, you can scale the amplitude of the track to be played back. Values larger than 1 result in more intense haptic effects, values smaller than 1 result in less intense haptic effects. Note that you cannot exceed 100% of total intensity, that is, if your track features e.g. a vibration with 50% amplitude, the maximum scale you can use is 2.0, if your track features e.g. a vibration with 100% amplitude, the maximum scale you can use is 1.0.

Hapticlabs.SetAmplitudeScale(float amplitudeScale);

With this command, you can adjust the amplitude of the playback.

  • amplitudeScale: with this parameter, you can scale the amplitude of the playback. Values larger than 1 result in more intense haptic effects, values smaller than 1 result in less intense haptic effects. Note that you cannot exceed 100% of total intensity, that is, if your track features e.g. a vibration with 50% amplitude, the maximum scale you can use is 2.0, if your track features e.g. a vibration with 100% amplitude, the maximum scale you can use is 1.0.

Hapticlabs.Stop();

With this command, you can terminate any haptic playback.

By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.