Skip to main content

Guide for Unreal

Using our Unreal SDK Plugin, you can implement the haptic into your content made with Unreal.

  1. Import SDK Plugin
  2. Link the Haptic App
  3. Add Prefab to Initialize
  4. (Optional) Prepare for C++

Prerequisite

If you want to use haptic feature in your game, the haptic application should be linked to your game. Make sure you have a haptic application(haptic app, for short) corresponding to your game.

note

You can create and manage haptic apps in Developer Portal(Portal, for short), a web-based program. If you don't know about haptic app or don't have one, please visit Portal first and make your own haptic app. (Protip: Use template to make the app quickly) Developer Portal

Prepare your haptic app

To link the haptic app to the game, the haptic app should meet these requirements. Go to your haptic app in the Portal, and check these requirements.

  • Haptic app should contain at least one haptic event
    • The event named game_start already exists, unless you manually removed it.
  • API Key should be generated
    • There is no API Key until you generate it. Go to the "API Key" tab and click "New" button to generate one.
  • Haptic app should be deployed
    • If you see "Deploy Now" button on the top right, press it to deploy your haptic app. Otherwise, if you can see "Up to date", it means that the latest haptic app has already been deployed.

Get App ID & API Key

Link process requires App ID and API Key which can be browsed in the "Settings" tab. Go to the "Settings" tab, and check the App ID and API Key.

Slide 16_9 - 9.png

Import SDK Plugin

There are two ways to import the SDK plugin into your Unreal project.

  • If your project's Unreal version is 5.0 - 5.4, you can get a plugin from Unreal Marketplace.
  • If your project's Unreal version is 4.26 - 5.4, you can download the plugin files, and add them to your project.
  1. Get bHaptics Plugin from Unreal Marketplace. bHapticsPlugin in Code Plugins - UE Marketplace - Chrome 2024-04-29 오후 5_14_01.png
  2. Go to Epic Games Launcher to install plugin to engine. Installing plugin in Epic Games Launcher
    1. At the left, Select "Unreal Engine" tab.
    2. At the top, Select "Library" tab.
    3. Scroll down to Vault, and search "bhaptics".
    4. Find "bHapticsPlugin", and select "Install to Engine".
    5. Select your game engine version you want to use.
    6. Select "Install". The download will begin immediately.
    note

    For more information about plugin in Unreal, visit official Unreal Documentation.

  3. Activate the plugin.
    1. Open the Unreal project which you want to use bHaptics.
    2. Open the Plugins window. Slide 16_9 - 10.png
      1. In the toolbar, select "Settings".
      2. In the dropdown, select "Plugins". Then the Plugins window will appear.
    3. Activate "BhapticsPlugin". Frame 79.png
      1. Search "bhaptics".
      2. Check "BhapticsPlugin" to activate.
      3. The warning will appear. Press "Restart Now". (Make sure you save your project first if you have any changes!)
    4. After restarting the editor, open the Plugins window again, and check that "BhapticsPlugin" is enabled.
  1. Open the Project Settings.
  2. Go to bHaptics plugin settings. Untitled
  3. Put the App ID, API Key of your haptic app, and press "Link bHaptics" button. App ID and API key can be found in Portal.
  4. If the project is successfully synchronized with bHaptics Developer portal, you will receive following message BHAPTICS_SETTINGS_SUCCESS. Untitled
  5. Open [YourUEProjectName].sln, right-click the project name in the Solution Explorer, and select "Rebuild" to compile the project source.
  6. Open your Unreal project, and go to Plugin settings. Check that "BhapticsPlugin" in Haptic section is enabled.

Set Haptic Environment

Before using haptic-related functions, you must initialize the haptic environment. The initialization should be made at the beginning of the game. Also, you should destroy the haptic environment when the game is ended.

We provide both Blueprint and C++ methods for these functionalities.

  • Blueprint
    • Initalize: Call "Initialize bHaptics" Node
    • Destroy: Call "Destroy bHaptics" Node
  • C++
    • Initalize: Invoke UBhapticsSDK2::Initialize() Function
    • Destroy: Invoke UBhapticsSDK2::Destroy() Function

Also, you must notice that:

  • You can initialize multiple times. This will not cause any efficiency problem.
  • You MUST DESTROY at the last level where the program ends, and you must do it ONLY ONCE. It can cause crashes if you don't destroy or destroy more than once.

We offer two options. Feel free to choose the one that suits your needs.

  • Via GameInstance (Recommended)
  • Via Level Blueprint

Via GameInstance

The game instance is instantiated on engine launch and remains active until the engine shuts down.

"Gameplay Framework" — Unreal Documentation

  1. Create new Blueprint Class inherit from "GameInstance". Untitled
  2. Name it as you want, and open its Event Graph. Untitled
  3. Setup the Event Graph, and compile/save. Untitled
    • Initialize: Connect "Initialize bHaptics" after "Event Init".
    • Destroy: Connect "Destroy bHaptics" after "Event Shutdown".
  4. Go to Project Settings → Project → Maps & Modes, and set Game Instance Class as what you've just made. Untitled

Via Level Blueprint

  1. Open the Level Blueprint. Frame 80.png
  2. Setup the Event Graph, and compile/save. Untitled
    • Initialize: Connect "Initialize bHaptics" after "Event BeginPlay".
    • Destroy: Connect "Destroy bHaptics" after "Event End Play".

(Optional) Prepare for C++

If you're using C++ in your Unreal project, there are some additional required processes.

  1. Move to Source/[YourGameName]/[YourGameName].Build.cs and add dependency.
    Source/[YourGameName]/[YourGameName].Build.cs
    // Add Dependency

    PrivateDependencyModuleNames.Add("BhapticsPlugin");

    // Or Using AddRange

    PrivateDependencyModuleNames.AddRange(new string[] { "BhapticsPlugin" });
    note

    After you modify the Build.cs file, you must regenerate the project files, and rebuild the engine.

    1. Regenerate the project files: Go to your Unreal project in the file explorer, right-click the [YourUEProjectName].uproject file, and select "Generate Visual Studio Project Files".
    2. Rebuild the engine: Open [YourUEProjectName].sln, right-click the project name in the Solution Explorer, and select "Rebuild".
  2. Include "BhapticsSDK2.h" header in your C++ script which uses the haptic features.
    #include "CppGameModeBase.h"
    #include "BhapticsSDK2.h"

    void CppGameModeBase::BeginPlay()
    {
    Super::BeginPlay();

    UBhapticsSDK2::Initialize();
    }

Further Reading

You're now ready to use the bHaptics haptic feature! Visit our Unreal Reference page to play haptics in your game.

Troubleshooting

If you can't find the module, please refer to this page.