Haptic
Hardware-agnostic haptics: publishes request events for UnityHapticAdapter. Honors hapticsEnabled (synced with Setting in normal flows).
Adapter: UnityHapticAdapter.
State (Persistent)
| Key | Purpose |
|---|---|
hapticsEnabled | Mirrors 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 id | Kind |
|---|---|
REQUEST_HAPTIC_PLAY_PRESET | Request |
REQUEST_HAPTIC_PLAY_EMPHASIS | Request |
REQUEST_HAPTIC_PLAY_CONSTANT | Request |
REQUEST_HAPTIC_PLAY_CLIP | Request |
REQUEST_HAPTIC_STOP_ALL | Request |
REQUEST_HAPTIC_PLAY_PIECE_FEEDBACK | Request |
Payload field names (preset, amplitude, clipResourcePath, pieceFeedbackKind, …) are PAYLOAD_* on the same class.
Functions
| Function | Parameters |
|---|---|
PlayPreset | preset (e.g. LightImpact, MediumImpact, Success, …) |
PlayEmphasis | amplitude, frequency (0–1, defaults 1) |
PlayConstant | amplitude, frequency, duration (seconds) |
PlayClip | clipResourcePath (Resources path), optional loop, seekTime, clipLevel, frequencyShift, fallbackPreset |
PlayPieceFeedback | pieceFeedbackKind (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