====== How to Integrate bhaptics SDK into Unity - Daniel ====== ===== Introduction ===== This guide contains steps on how to install and integrate the bhaptics tactile vibration SDK into a Unity project using bHaptics developer. This allows sending tactile feedback to bhaptics devices inside a Unity Project. This guide will use bhaptics Tactgloves as an example, however, the steps should work with all bhpatic devices. ===== Requirements ===== * Unity 2019.4 or later * bhaptics Player SDK * One of the types of bhaptics hardware (vest, gloves, etc.). ===== Install bHaptics Player ===== Download bHaptics player at the following link: https://www.bhaptics.com/software/player. Once installed, Login and follow setup instructions. Within the player, you can pair your devices as instructed by the manual associated with the bhaptic tool you plan to connect. In the case of Tactgloves, this is done via turning them on and pairing them under the device settings in bhaptics player. Once paired, can test the device by pressing ping. This should send a haptic signal given that pairing worked correctly. ===== Preparing bHaptics Developer Portal to Sync with Unity ===== * Log in to bHaptics Developer Portal at https://developer.bhaptics.com * Click on create a new project {{:playground:bhaptics_developer_intro.png?600|}} * You can either choose an empty project or to use a template. In this case, we will use the shooting template. * Retrieve API key and Project ID to use in Unity. This can be down by going to the API subsection and pressing **NEW** to generate a usable API key. * Once API key is generated, go to settings. API key and APP ID should be there. Keep this in mind for reference in Unity later on. {{:playground:bhaptics_unitysdk_developerapi.png?600|}} * Press **Deploy Now** to make haptic events reachable from Unity ===== Importing Deployed Events into Unity ===== * Download bHaptics haptic plugin for unity at https://assetstore.unity.com/packages/tools/integration/bhaptics-haptic-plugin-76647 * Once downloaded, install plugin into unity by following install instructions * Open bHaptics plugin by going to **My Assets** from the **Explore** option under the **Services** tab. Then import the bhaptics plugin to your project. {{images:ar_chess:bhaptics_unitysdk_unitypackdagemanager.png?600|}} * Once bhaptics is imported, you can sync bhaptics by clicking on developer window and entering your unique **APP ID** and **API Key**. * This will only work if you already pressed deploy on your bhaptics developer template {{:playground:bhaptics_unitysdk_unitydeveloperapi.png?600|}} This will link your bhaptics template to your unity project. It will show you documentation you can use to develop your haptic effects and how to combine them. ===== Add bhaptics Objects ===== - Create a new ''BhapticsManager'' object (menu: bhaptics > Bhaptics Manager) - Create a new ''BhapticsReceiver'' object (menu: bhaptics > Bhaptics Receiver) - Position both objects under a manager object in the hierarchy. ===== Send Haptic Feedback ===== To send haptic feedback call: '' BhapticsManager.instance.SubmitRegistered("HapticKey", position, intensity); '' ===== Conclusion ===== The bhaptics SDK is now integrated into your Unity project. You can send haptic feedback to bhaptics devices by calling the ''SubmitRegistered()'' method. Refer to the bhaptics documentation for more advanced usage.