Unreal plugin architecture & API
How the HexR plugin is built, its Blueprint and C++ API, and how it maps onto the Unity package.
This page describes the HexR plugin 0.2.0 for Unreal Engine 5.8.
What is in the plugin
| Module | What | In your Build.cs |
|---|---|---|
HexRCore | The glove protocol, with no gameplay code: the command encoder, the readings decoder, the haptic scheduler behind the glove effects, and the shared types (EHexRHand, EHexRFinger, EHexRChannels) | Yes, with HexR |
HexRBle | Bluetooth LE: Windows’ own Bluetooth (WinRT), Android’s through Java, and simulated gloves for tests and machines without Bluetooth | Rarely |
HexR | The gloves and their manager, the tracked hands and touch points, the Pressure Controller, the components, the HexR Pawn, the HexR menu, VR Template grabs, Unreal’s haptics on the gloves and the project settings | Yes |
HexRPassthrough | Passthrough on Quest and PICO through Unreal’s own OpenXR, and the HexR Passthrough Visibility component | To switch passthrough from C++ |
HexRRemote | HexR Remote: the network server the HexR Companion app talks to, and the Android capture of the view and its sound | For HexR Remote commands from C++ |
HexREditor | The Tools → HexR menu, the HexR Tools tab and the project validator. Also two command-line tools, run with UnrealEditor-Cmd -run=: HexRValidate and HexRMakeSamples | No, editor only |
Content/ | BP_HexRRig, BP_HexRMenu, the example Blueprints and the L_HexRDemo level | — |
The automation tests are a separate development plugin, HexRTests. The zip leaves them out.
Everything a game uses is a UCLASS with Blueprint-callable functions and Blueprint-assignable events, so Blueprint and C++ see the same API. Blueprint shows the names with spaces: ConnectHand is the Connect Hand node. Each function’s comment in Plugins/HexR/Source/*/Public is the node’s tooltip.
Wire compatibility
The plugin sends the glove the same bytes as the Unity package. Its tests compare 555 encoded commands with the Unity package’s output. The Godot addon is checked against the same set.
Connecting the glove
- A connect scans for
HaptGloveAR LeftorHaptGloveAR Right, or a custom name. Or it goes straight to the glove it remembers, stored per platform inSaved/HexR/Devices.ini. - One scan serves both hands. A failed attempt retries after 1, 2, 4 and 8 seconds, for up to a minute. A silent attempt restarts after 20 seconds, and a dropped glove reconnects by itself.
- The glove’s air pump starts 2 seconds after it connects.
- On Android, commands go out at most every 100 ms, batched. Releases skip the queue. When the app pauses, Android’s side writes the release itself, because the game loop has stopped.
- One process, one connection:
UHexREngineSubsystemowns the gloves, so the editor’s HexR Tools and a game played in the editor share them.UHexRSubsystemreleases every channel when the game ends.
Blueprint and C++ API
The calls most games use.
UHexRSubsystem: where to start
| Member | Does |
|---|---|
UHexRSubsystem::Get(WorldContext) | The game instance’s HEXR subsystem. In Blueprint, the Get HexRSubsystem node |
GetManager() | The manager that owns both gloves |
GetGlove(Hand), GetLeftGlove(), GetRightGlove() | One glove |
UHexREngineSubsystem::Get() | The same manager outside a game, for editor tools |
UHexRManager: both gloves
| Member | Does |
|---|---|
ConnectHand(Hand) | Connect that hand’s glove. Asks for the Bluetooth permission where needed, then scans or goes straight to the remembered glove. Does nothing if it is connected or connecting |
DisconnectHand(Hand) | Release the glove, then disconnect it |
ToggleHand(Hand) | Connect, cancel a connect in progress, or disconnect: what a Connect button does |
IsHandConnected(Hand), IsHandConnecting(Hand) | Connected now; a connect under way, including a wait between retries |
SearchNearbyGloves(), ConnectTo(Hand, Address) | List the gloves in range, then connect one of them |
ForgetGlove(Hand), GetSavedGloveAddress(Hand) | The remembered glove |
GetGlove(Hand) | One glove |
GetTransportKind() | Which Bluetooth is in use: Windows, Android or simulated |
UHexRGlove: one glove
| Member | Does |
|---|---|
Press(Channels, Intensity, Speed) | Steady pressure until released |
PressHand(Channels, PalmIntensity, FingerIntensity, Speed) | The palm and the fingers at different strengths, in one write |
Vibrate(Channels, Frequency, Intensity) | Vibration until stopped |
StopVibration(Channels) | Stop the vibration; a steady press keeps pressing |
Release(Channels) | Pressure and vibration off |
Pulse(Channels, Intensity, HoldSeconds, Speed) | A press that lets go by itself, after 0.08 s at least |
PulseHand(Channels, PalmIntensity, FingerIntensity, HoldSeconds, Speed) | A pulse with the palm and the fingers at different strengths |
SendPressure(Finger, bOn, Intensity, Speed), SendVibration(Finger, bOn, Frequency, Intensity) | One channel, sent as it is |
ReleaseAllChannels(), ReleaseChannels(Fingers) | Let go of everything, or of some channels |
GetChannelState(Finger) | What was last sent to a channel |
GetBatteryLevel(), GetBatteryState(), GetAirPressureKpa() | Readings from the glove |
IsConnected(), IsConnecting(), GetStatusText(), GetGloveName() | Its state, as the HexR menu shows it |
RememberDevice(Id), ForgetDevice(), ConnectToDevice(Id) | The glove this platform remembers |
bUseCustomDeviceName, CustomDeviceName | Connect to a glove with another name |
Channel masks. The effects take an EHexRChannels mask. In Blueprint, tick the channels on the pin. In C++, HexR::ChannelBit(Finger), HexR::ChannelsFingers, HexR::ChannelsPalm and HexR::ChannelsAll make it.
How the effects are sent. Press, Vibrate, Pulse and the rest go through FHexRHapticScheduler, ported from the HEXR Sandbox demo app. It keeps what each channel should be doing and sends only what changed, at most six commands per write. It times each pulse from the write that actually carries it, so a short pulse survives Bluetooth batching. A pulse lasts at least 80 ms, below which it isn’t reliably felt.
UHexRPressureController: one hand’s haptics
| Member | Does |
|---|---|
SingleThumbHaptic(Intensity) … SinglePalmHaptic | Press one channel |
RemoveThumbHaptics() … RemovePalmHaptics() | Release one channel |
CustomSingleHaptics(Finger, bOn, Intensity, Speed, bBypassHandCheck) | Press one channel, optionally skipping the hand-near check |
CustomSingleVibrations(Finger, bOn, Intensity, Frequency, bBypassHandCheck) | Vibrate one channel |
TriggerAllHapticsIncrease(Intensity), TriggerCustomHapticsIncrease(Fingers, Intensity, Speed) | Press every channel, or the chosen ones |
TriggerAllVibrations, TriggerCustomVibrations(Fingers, Intensity, Frequency) | Vibrate every channel, or the chosen ones |
TriggerPinchPressure(Intensity), RemovePinchPressure() | The thumb and index together |
TriggerPulseIt(Intensity) | One short pulse on every channel |
RemoveAllHaptics(), RemoveAllVibrations() | Release the whole hand |
HandGrabbingCheck(bOn), PokeHoveringCheck(bOn), IsHandNear() | Open or close the hand-near check, and read it |
GetPressuresKpa(), GetPressuresRaw() | The glove’s pressure readings |
GetGlove() | This hand’s glove |
UHexRTouchLibrary: static helpers
| Member | Does |
|---|---|
GetTouchPointInfo(Component, Hand, Finger) | Whether a component is a touch point, and whose |
TriggerFixPressure(TouchPoint, Intensity), RemoveHaptics(TouchPoint) | Press or release the channel a touch point belongs to |
TriggerVibration(TouchPoint, Frequency, Intensity), RemoveVibration(TouchPoint) | Vibrate it, or stop |
GetGlove(Hand), GetPressureController(WorldContext, Hand) | Find a glove or a Pressure Controller |
StrengthToIntensity(Strength) | A component strength (10–60) as an intensity (0.1–1) |
UHexRTrackedHandComponent: a tracked hand
| Member | Does |
|---|---|
IsTracking(), event OnTrackingChanged | Whether the headset sees the hand, and when that changes |
GetFingerUse() | How curled each finger is, from 0 (curled) to 1 (straight) |
GetTouchPoint(Finger) | One touch point |
bShowHand, JointMesh, BoneMesh, HandMaterial, JointRadius, BoneRadius | The hand it draws |
bShowTouchPoints, TipRadius, TipOffsets, PalmSize, PalmOffset | The touch points, in centimetres |
UHexRWorldSubsystem returns the level’s tracked hand and Pressure Controller for each hand.
AHexRPawn and AHexRMenu
| Member | Does |
|---|---|
AHexRPawn: Camera, LeftHand, RightHand, LeftPressure, RightPressure, Recenter | The rig’s components |
bConnectGlovesOnBeginPlay, bFloorTrackingOrigin, SetShowTouchPoints(bShow) | Connect when play starts; track from the floor; show the touch points |
AHexRMenu: ToggleMenu(), SetMenuVisible(bVisible), IsMenuVisible(), Summon() | Show, hide or bring the menu in front of the wearer |
Demos, event OnDemo(Index), bShowRestart, RestartLevel() | Your own buttons, and Restart |
PanelWidth, bFingerPress, Handle | Its size, fingertip pressing, and the header the wearer pinches to move it |
bFollowWearer, Distance, Drop, FollowDistance, FollowAngle | Following the wearer, and where it sits when it does |
Zones and effect components
| Member | Does |
|---|---|
Every zone: OnTouchBegin(Hand, Finger, TouchPoint), OnTouchEnd, GetTouchingChannels(Hand) | A fingertip or the palm came in or left; what touches it now |
UHexRGrabbableComponent: GrabTarget, bSimulatePhysicsOnRelease, GetGrabTarget() | What moves with the hand; dropping with physics |
UHexRFireComponent: Ignite(), Extinguish(), IsLit(), OnIgnited, OnExtinguished | Light it, put it out, and hear about it |
UHexRWaterComponent: GetWetChannels(Hand), OnSplash | Which channels are in the water; a hand went in |
UHexRHeartbeatComponent: SetRhythm(Rhythm), GetRhythm(), GetBpm(), OnBeat | Change the rhythm, read the rate, and hear each beat |
UHexRReturnHomeComponent: OnReturnedHome | The object is back where it started |
Passthrough
| Member | Does |
|---|---|
UHexRPassthroughLibrary::IsPassthroughAvailable() | The headset can show the room now |
IsPassthroughOn(), SetPassthroughOn(bOn) | Whether the room shows, and switching it |
UHexRPassthroughVisibilityComponent: Visibility, IsHidingOwner() | Hide in Passthrough or Only in Passthrough; whether it is hiding its actor now |
Events
| Event | When |
|---|---|
OnGloveConnected(Hand) | A glove connected |
OnGloveDisconnected(Hand) | A glove’s link went down. IsHandConnecting is true if it is reconnecting by itself |
OnGloveConnectFailed(Hand) | One attempt failed; it may still retry |
OnConnectAttemptEnded(Hand) | The attempts ended without a connection: it gave up, was cancelled or wasn’t permitted |
OnBatteryStateChanged, OnPumpChanged | The battery reading, or the air pump, changed |
OnStatusChanged | A glove’s status text changed: what the HexR menu shows |
OnDeviceFound, OnNearbySearchEnded | A scan saw a glove; a nearby search finished |
These are on UHexRManager, for both gloves. Each UHexRGlove has the same kind of events for itself alone, such as OnConnected and OnDisconnected.
Coming from Unity
The classes keep the Unity package’s names, with Unreal’s prefixes, and their members are Unity’s in Unreal’s PascalCase: typeOfHaptics becomes TypeOfHaptics. Where Unreal differs, and why:
| Unity package | Unreal plugin | Why |
|---|---|---|
HexRManager.Instance | UHexRSubsystem (game instance) → GetManager() | Unreal’s singletons are subsystems. The manager lives in UHexREngineSubsystem, so the editor and Play share one connection |
| HexR Main, HexR → Create HexR Rig | AHexRPawn / BP_HexRRig, Tools → HexR → Add HexR Rig to Level | A pawn with the hands on it |
| The HexR menu | AHexRMenu / BP_HexRMenu | The same layout, colours and type, drawn in Slate |
HaptGloveHandler | UHexRGlove | Unreal’s class prefix |
PressureTrackerMain | UHexRPressureController | An actor component on the pawn |
HexRTrackedHand, HapticFingerTrigger | UHexRTrackedHandComponent, UHexRFingerTouchPointComponent, UHexRPalmTouchPointComponent | Components; UHexRTouchLibrary holds the finger trigger’s calls |
FingerUseTracking | FHexRFingerUse | Curl is measured by bone ratio by default. The Unity package’s way is the Self Calibrating curl measure |
HexRGrabbable, SpecialHaptics, … | UHexRGrabbableComponent, UHexRSpecialHapticsComponent, … | Box components |
| The HEXR Sandbox’s fire, fountain and heart | UHexRFireComponent, UHexRWaterComponent, UHexRHeartbeatComponent | Part of the plugin, not only of a demo |
The HEXR Sandbox’s GloveHaptics pump | UHexRGlove Press, Pulse and the rest, through FHexRHapticScheduler | On the glove itself |
Connect / Disconnect(hand) | ConnectHand / DisconnectHand(hand) | Same behaviour |
ConnectLeftBT() / ConnectRightBT() | ToggleHand(hand) | One call for both hands |
HaptGloveHandler.HandType | EHexRHand | |
Haptics.Finger | EHexRFinger everywhere | One channel order, the glove’s |
UnityEvents onBluetoothConnected, onPressed | delegates OnConnected, OnButtonPressed | Blueprint-assignable multicast delegates |
OnReleased on HexRGrabbable / buttons | OnGrabReleased, OnButtonReleased | Unreal’s components already have an OnReleased |
HEXRPressure and the other builders | UHexRGlove::SendPressure, SendVibration, or GetHaptics() with BTSend | |
| HexR editor menu, HexR Tools | Tools → HexR, Tools → HexR Tools, Project Settings → Plugins → HexR, console commands | |
| Package Manager git URL | The plugin zip, unzipped into Plugins/ | Unreal installs project plugins as folders |
Console commands
HexR.Status prints Bluetooth's and both gloves' state to the log
HexR.Connect Left connects the left glove (or cancels a connect, or disconnects)
HexR.Connect Right
HexR.Menu shows or hides the HexR menu (HexR.Menu Show, HexR.Menu Hide)HexR Remote
HexR Remote lets a phone on the same Wi-Fi find your app and control it, from the HexR Companion app’s Headsets tab. It is the HexRRemote module. It is off by default, because it opens network ports and can ask to share what the wearer sees.
Turn it on
Tick Enabled in Project Settings → Plugins → HexR Remote, and Enable in Editor for the editor’s Play sessions. Or call Start Remote on UHexRRemoteSubsystem, a game instance subsystem. It also has StopRemote(), IsRemoteRunning(), GetControlPort(), GetPhonesConnected() and GetPhonesWatching().
What a phone may do
- Allow Glove Control: connect, disconnect or forget a glove, search for gloves nearby, release and test every channel.
- Allow Video: see the headset view, on Android only. The wearer accepts Android’s screen-sharing prompt in the headset each session.
- Expose Scenes, with Scenes: switch between the levels you list.
- Allow Recenter: recenter the wearer. The pawn needs a HexR Recenter component.
Sharing the view
Video Width, Video Height, Video Bitrate Kbps and Video Fps set the video. Share Sound adds the app’s own sound, never the microphone’s. Android guards that capture with the microphone permission, so RECORD_AUDIO is added to the build only while the view and its sound are both shared.
Your own buttons
The Blueprint node Register Remote Command (Id, Label, an event) puts a button on the phone. The event runs on the game thread. Unregister Remote Command removes it. From C++, UHexRRemoteSubsystem::RegisterNativeCommand takes any callable; add HexRRemote to your Build.cs for it.
Ports
| Port | Used for |
|---|---|
UDP 47800 | Phones finding the app |
TCP 47801 | Control |
TCP 47802, 47803 | Video and sound |
If a TCP port is taken, the next free one is used and announced. It speaks the same RemoteProtocol, version 1, as the Unity package, so the HexR Companion treats Unreal and Unity apps alike.
The protocol and the server pass their automation tests, but HexR Remote has not yet been tried with the HexR Companion app or on a headset.
HexR Remote is not authenticated: anyone on the same Wi-Fi with a HexR Remote client can control the gloves. Bring a dedicated router to events.
How it is tested
The automation tests are in Tools → Session Frontend → Automation; filter for HexR. All 63 pass. They cover:
- the bytes sent to the glove, against the Unity package’s;
- connecting, against a simulated glove;
- the haptic scheduler, the tracked hands, and every component through real overlap queries;
- VR Template grabs and Unreal’s haptics on the gloves;
- passthrough visibility and the menu’s layout;
- the editor tools, the validator, the demo level and the examples;
- HexR Remote’s protocol and server.
Beyond the tests, the prebuilt zip opens in a Blueprint-only project with no compiler, and that project packages for Android. On a Meta Quest 3 with real gloves, the gloves connect over Bluetooth and the haptics play. On a PICO 4 the app runs in passthrough; gloves there, and on Windows, have not been tried yet.