Android Haptics
by Mobuos
Godot Android Haptics Plugin
A plugin to add support to clear and rich haptics, as opposed to the default buzzy haptics that Godot offers.
Installation
Grab the zipped addons.zip
from releases, and unzip its contents into the root folder of your project. After that you should be able to enable the plugin in Project -> Project Settings -> Plugins. Also make sure the "Vibrate" permission is allowed in Project -> Export / Android window.
You can also now install directly through Godot, as this plugin is available on the Asset Store! Just note it might not be the most up-to-date version :)
Usage
Check haptics_wrapper.gd
, but in short:
haptics = AndroidHaptics.new()
haptics.vibratePrimitive(AndroidHaptics.Primitive.THUD, 0.5) # primitive, intensity
haptics.vibrateEffect(AndroidHaptics.Effect.TICK) # effect
haptics.Composition.new()\
.addPrimitive(AndroidHaptics.Primitive.SLOW_RISE, 1.0)\
.addPrimitive(AndroidHaptics.Primitive.THUD, 1.0, 500)\
.vibrate() # primitive, intensity, delay(ms)
Recommendations
There's likely no better resource than the Android documentation itself: https://developer.android.com/develop/ui/views/haptics.
Most functions provided here will work very similarly to the ones used in native Android code. Not only that, the high level concepts can be easily re-used as well:
At a high level, the design guidelines can be summarized as:
- Favor rich and clear haptics over buzzy haptics.
- Be consistent, both with the system and the app design.
- Be mindful of frequency of use, and importance.
Building
Check https://github.com/m4gr3d/Godot-Android-Plugin-Template and https://docs.godotengine.org/en/stable/tutorials/platform/android/android_plugin.html.
The final output should be in demo/addons/GodotAndroidHaptics
Download
Support
If you need help or have questions about this plugin, please contact the author.
Contact Author