Haptic Feedback

Godot 4.2 Mono

Could someone explain in detail about the vibration code for XRController3D, I mean the detailed designation of all the arguments of this method.

public void TriggerHapticPulse(string actionName, double frequency, double amplitude, double durationSec, double delaySec)

The official documentation explains this method very briefly.
Are all parameters 0 - 1 and what does the string variable “Action” mean, etc.

All input and output in XR is governed by the action map. For haptic feedback you need to create one or more haptic actions and then bind them to actual haptic output devices for each controller profile you support.

The default action map defines an action called “haptic” so if you haven’t edited the action map, that is likely the action you want to use here.

If the docs state frequency is between 0 and 1 than I think that’s wrong, you actually specify a vibration frequency in Hz. For OpenXR if you leave this at 0.0 , the XR runtime will select a frequency that works well for the haptic of the device.

Amplitude is a value between 0.0 to 1.0 and basically sets the strength of the rumble.

DurationSec is how long the rumble lasts in seconds.

DelaySec allows for a delay before the rumble starts after it is triggered.

1 Like

Thanks for the detailed answer. Tell me, will the oscillation frequency that you wrote about - its maximum value - not affect the compatibility of platforms? I mean, if we set a large value that the platform does not support, will everything work? Are there default frequency standards that all platforms support?

Honestly, I think you hit the nail on the head with that question. I really don’t know. The OpenXR specification really doesn’t offer any guidance here so we’re mostly at the mercy of how each platform implements haptics.

It’s reasonable to assume that values that work well with one controller will behave similar on other controllers as they all implement similar rumblers, but there is no guarantee. You’ll need to experiment with different controllers.

Haptics sadly is an area where there isn’t a whole lot of experimentation going on, most people see it as an after thought. I do hope this will change and we’ll get a bigger body of knowledge around it.

1 Like