Skip to Content

Haptic

Hardware-agnostic haptics: publishes request events for UnityHapticAdapter. Honors hapticsEnabled (synced with Setting in normal flows).

Adapter: UnityHapticAdapter.

State (Persistent)

KeyPurpose
hapticsEnabledMirrors HapticsEnabled property (bool)

How it looks in persistent.json

hapticsEnabled normally lives on Persistent next to other settings (same field Setting reads for display).

persistent.json
{ "Persistent": { "hapticsEnabled": true } }

Events

Request ids are in GnosisHapticEvents (Runtime/GnosisEngine/Source/Services/Persistent/Services/Haptic/). The service publishes request events for adapters (e.g. UnityHapticAdapter); there are no FACT_* haptic outcomes defined on this class — playback is adapter-side.

Event idKind
REQUEST_HAPTIC_PLAY_PRESETRequest
REQUEST_HAPTIC_PLAY_EMPHASISRequest
REQUEST_HAPTIC_PLAY_CONSTANTRequest
REQUEST_HAPTIC_PLAY_CLIPRequest
REQUEST_HAPTIC_STOP_ALLRequest
REQUEST_HAPTIC_PLAY_PIECE_FEEDBACKRequest

Payload field names (preset, amplitude, clipResourcePath, pieceFeedbackKind, …) are PAYLOAD_* on the same class.

Functions

FunctionParameters
PlayPresetpreset (e.g. LightImpact, MediumImpact, Success, …)
PlayEmphasisamplitude, frequency (0–1, defaults 1)
PlayConstantamplitude, frequency, duration (seconds)
PlayClipclipResourcePath (Resources path), optional loop, seekTime, clipLevel, frequencyShift, fallbackPreset
PlayPieceFeedbackpieceFeedbackKind (Move, Rotate, HardDrop, Discard, GameOver, Victory) — optional game-specific preset envelope
StopAll

If haptics disabled, calls no-op Ok for presets/emphasis/etc.

Usage example — PlayPreset

HapticService.Example1.cs
private void PlaySuccessHaptic() { if (Context?.Store == null || Context.CallService == null) return; var args = GnosisNode.CreateObject(Context.Store); args.Set("preset", "LightImpact"); CallService("Haptic", "PlayPreset", args); }

Statistics

None.

Last updated on