Controlling Haptics via code

We’re trying to use FMOD haptics for our vibrations on PS5 and Switch2 platforms. One issue we have is how to implement a way to give player option to turn it off or lower the power. Also when game gets paused we set the buses to paused, but this doesn’t seem to stop the haptics effects that are already playing. Is there any way to pause or “mute” haptics via code?

Hi,

Thank you for sharing the information.

For now the best workaround would be to control the haptics intensity through a global parameter.

For example, you could create a global continuous parameter such as HapticIntensity and use it to automate the Left/Right intensity of your Haptics Instruments.


Then in Unity, you can set the value via Studio::System::setParameterByName

When the game is paused, set this parameter to 0, then restore it to the player’s selected value when the game is unpaused.

This should allow you to handle both the player vibration strength option and the pause menu case for any haptics clips using that global parameter.

Hope this helps! Let me know if you have more questions.

Are there any plans to support Switch2 and other platforms? Right now I can see that there are libfmod_haptics in lib folder, but there is no way to load it either as dynamic or static lib in our builds, and the banks containing haptics instruments also fail loading when running on Switch2 DevKit.

Switch 2 haptics is supported. The currently listed haptics supported devices/platforms can be found in Haptics

Could I please get a screenshot of how your static plugin is set up in Unity?

You may have already tried this, but just to double check, could you please try adding the haptics plugin as a Static Plugin in the Switch 2 platform settings?

You can find more information about Unity static plugins here: Static Plugin

In FMOD Settings > Platform Specific > Switch 2 > Static Plugins, try adding:

FMOD_Haptics_GetDSPDescription

If the bank still fails to load, could you please share the full bank loading error, along with the exact FMOD Studio and Unity integration version you are using?

This solutions works. But we have another problem when turning on Stripping level on player settings we get the old error while loading the banks (we changed the exceptions to error messages so that game would still run):

[FMOD] PostLoad::initPluginEffects : DSP plugin returned an error, bank will not load properly.
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object)
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
FMODUnity.RuntimeUtils:DebugLogError(String) (at D:\dev\goldman-switch\Assets\Plugins\FMOD\src\RuntimeUtils.cs:596)
FMODUnity.RuntimeManager:DEBUG_CALLBACK(DEBUG_FLAGS, IntPtr, Int32, IntPtr, IntPtr) (at D:\dev\goldman-switch\Assets\Plugins\FMOD\src\RuntimeManager.cs:107)

Error loading bank: rom:/Data/StreamingAssets/Desktop/Haptic.bank
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object)
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
FMODUnity.RuntimeManager:RegisterLoadedBank(LoadedBank, String, String, Boolean, RESULT) (at D:\dev\goldman-switch\Assets\Plugins\FMOD\src\RuntimeManager.cs:869)
FMODUnity.RuntimeManager:LoadBank(String, Boolean, String) (at D:\dev\goldman-switch\Assets\Plugins\FMOD\src\RuntimeManager.cs:974)
FMODUnity.RuntimeManager:LoadBank(String, Boolean) (at D:\dev\goldman-switch\Assets\Plugins\FMOD\src\RuntimeManager.cs:925)
FMODSoundUtils:LoadAllBanks() (at D:\dev\goldman-switch\Assets\Scripts\Framework\Sound\FMODSoundUtils.cs:262)
Startup:Awake() (at D:\dev\goldman-switch\Assets\Scripts\Levels\Common\Startup.cs:39)

Adding FMOD to link.xml seems to fix this issue:

<assembly fullname="FMODUnity" preserve="all" />

Thank you for sharing the solution here!

Hey, I presume this method will basically work only if you haven’t already applied custom aputomation curves on haptic track?

I guess there is no way to actually create a universal multiplier that will alter haptics intensity at any given point? E.g. I automated haptics intensity to 0.5 via automation track manually. And if there was a general multiplier accessible accessible to the player and they decide to give it a 80% power, then haptics intensity would be 0.5*80% = 0.4?

Hi,

You are correct. I’ve tested this in 2.03 and confirmed that when multiple automation curves are applied to the Left/Right properties of a Haptics Instrument, their values are averaged rather than multiplied.

FMOD Studio 2.04 introduces a separate Intensity property that acts as a multiplier for the Left and Right properties. You can automate this property using a global parameter while preserving your existing Left/Right automation curves, which achieves exactly the behaviour you’ve described.

Unfortunately, I’m not aware of a straightforward way to achieve the same behaviour in 2.03.

May I ask which version of FMOD Studio you’re currently using?

We’re using 2.03, so yeah, it’s impossible to do there.

We will try to migrate to 2.04 (hopefully it won’t break anything). Will let you know of the results and if we managed to achieve the desired behavior.

Though is there an ETA of Unity verified version?

FMOD for Unity 2.04.00 is already Unity Verified. The downloads page currently displays the “Early Access” badge instead, but it qualifies as both.

Let us know how the migration to 2.04 goes!