https://github.com/mobuos/godot-android-haptics
Godot plugin that adds support to rich haptics on Android devices
https://github.com/mobuos/godot-android-haptics
android godot godot4 haptics
Last synced: about 1 month ago
JSON representation
Godot plugin that adds support to rich haptics on Android devices
- Host: GitHub
- URL: https://github.com/mobuos/godot-android-haptics
- Owner: Mobuos
- License: mit
- Created: 2024-12-12T16:10:52.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-14T19:29:09.000Z (4 months ago)
- Last Synced: 2025-03-25T10:21:22.246Z (about 2 months ago)
- Topics: android, godot, godot4, haptics
- Language: Kotlin
- Homepage: https://godotengine.org/asset-library/asset/3570
- Size: 385 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Godot Android Haptics Plugin
![]()
A plugin to add support to [clear](https://developer.android.com/develop/ui/views/haptics/haptics-principles#clear_haptics) and [rich](https://developer.android.com/develop/ui/views/haptics/haptics-principles#rich_haptics) haptics, as opposed to the default [buzzy](https://developer.android.com/develop/ui/views/haptics/haptics-principles#buzzy_haptics) haptics that [Godot offers](https://docs.godotengine.org/en/stable/classes/class_input.html#class-input-method-vibrate-handheld).
## 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:
```gdscripthaptics = 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`