This is a vibration module for Godot Game Engine 3 for Android & iOS (need testing).
To use this module you'll need a custom template for Android. You can build it by yourself or download a precompiled one.
This is harder, but you'll have more control over the building process. You can, for example, include any other module you want. For that, do the following steps:
- Clone or download this repository.
- Clone or download the Godot Engine repository. One important note here is that this must match the same version of the Godot editor you're using to develop your game.
- Drop the "vibration" directory inside the "modules" directory on the Godot source.
- Recompile the android export template following the official instructions.
If you don't want or can't build the template by yourself, you can find a precompiled template with this module here. Go to the release tab and download the zip file.
- In your project goto Export > Target > Android:
- Options:
- Custom Package:
- place the template apk you had compiled (or downloaded)
- Custom Package:
- Options:
- On the Android export options, check the Vibrate permission
- Add the following lines to
project.godot
:
[android]
modules="org/godotengine/godot/Vibration"
If you have more than one module separate them by comma.
- Drop the "vibration" directory inside the "modules" directory on the Godot source;
- Recompile the iOS export template following the official instructions.
- For exporting, follow the exporting to iOS official documentation.
- Export your project from Godot, it'll create an Xcode project;
- Copy the library (.a) you have compiled following the official documentation inside the exported Xcode project. You must override the 'your_project_name.a' file with this file.
The following methods are available:
# Make the device vibrates
# @param int duration the vibration duration in milliseconds (this parameter is ignored on iOS)
vibrate(duration)
In the demo directory you'll find a working sample project for Godot 3.