Interhaptics GameInput/XInput SDK
In this section we will show step by step how to add haptic effects to play on a Unity game using an GameInput / XInput controller. An example scene and scripts are already provided in the Core SDK and can be found in the Interhaptics Core SDK/Assets/Scenes/SampleScene_GameInput_XInput.unity path.
Step 1: Setting Up the Interhaptics Core SDK
The Interhaptics Core SDK can be installed via the Unity Package Manager as described in the documentation.
The GameInput/XInput controller can be setup up by setting it up through Unity Input Manager or through the new Input System package. If using the Input Manager, a preset file called InputManager-GameInput_XInput.preset can be found in the in the Interhaptics Core SDK\Assets\InputManager folder. Just click on it and the settings will be applied for the A,B,X,Y and DPad buttons.

Step 2: Adding GameObjects for Custom Haptics
Interhaptics Unity SDK 1.1.0 -- 1.2.3
Create an empty GameObject with the HapticManager component, which can be set to be persistent if desired.

Interhaptics Unity SDK 1.3.0 +
Do not add the HapticManager component, as HapticManager.cs is not a MonoBehaviour class from this version on.
Add HapticBodyPart components for the controller. Set the Body Part to Hand and the Side orientation to Left or Right if you want to separate the haptic motors or Global if you want to send haptic effects in an unified manner. If you want to use Spatial Haptic Sources have a Box Collider and a Rigidbody on the controller (Use Gravity set as false). This HapticBodyPart can be attached to the Player rig if needed and interact with different Spatial and Event Haptic Sources encountered in your game.
For each HapticBodyPart, there is a Debug Mode switch and a Target Intensity value which can be modified at runtime as well. It is working on Spatial Haptic Sources and the intensity is updated before each playback on mobile, or even during runtime on controllers (GameInput/XInput on PC, OpenXR or Meta Quest, consoles).


Step 3: Adding Haptic Effects
Create a normal GameObject, to act as a source for haptic feedback and add an EventHapticSource component to the GameObject. If you want to use a haptic effect in sync with an AudioSource you can use a variant of this component called AudioHapticSource which also adds the AudioSource. Both haptic source components can be added via the Inspector or through the Component -> Interhaptics option in the Unity top menu. On any HapticSource component, the following options can be set:
- Haptic Effect File: choose a haptic effect from the Unity SDK library of haps file or create your own with Haptic Composer by designing it or importing an audio file to create it (for Event, Audio, Spatial and normal Haptic Sources -- parent class, except Parametric Haptic Sources).
- Vibration Offset: starts haptic effect after the set seconds
- Source Intensity: the intensity of the haptic effect [value between 0 and 2]; it can be modified at runtime. On GameInput/XInput or console controllers / XR controllers, the intensity can be modified during the haptic effect playback.
- Debug Mode: shows in console when the haptic source starts and stops playing
- Is Looping: Check if you want the haptic effect to loop. If set to true, you can set a max loops or a max loop time value.
- Play At Start: starts playing once the GameObject is active
- Haptic Body Parts array: the Controller areas on which it will play the haptic effects. For GameInput controllers, set the Body Part to Palm (lower part of controller vibration motor), Index (upper or trigger part of controller vibration motor) or Hand (both parts -- lower and upper) and the side to where you want to target the haptic effect (left, right or global). XInput only controllers will work with just the Hand/Palm haptic body part.


- The Interhaptics SDK package includes over 30 haptic effects with accompanying audio, which can be selected for use.
- Custom haptic effects can also be imported and created with Haptic Composer. (Download | Documentation)
Step 4: Testing
- The haptic effects can be tested either by using the Play at Start check and activating/deactivating the GameObject on button press, either by calling the public method PlayEventVibration() on the EventHapticSource GameObject. A code snippet can be found bellow or in the GameInputXInputHapticController sample script from the Interhaptics Core SDK package.
using Interhaptics.Internal;
using Interhaptics.Utils;
using Interhaptics.Platforms.XInput;
//set the EventHapticSource here
public EventHapticSource eventHapticSource;
void Update()
{
if (Input.GetKeyDown(KeyCode.Joystick1Button0))
{
eventHapticSource.PlayEventVibration();
}
}