Native vibrator plugin for Unity Android.
Available now on the Asset Store:
Asset Store entry
Works with both Basic and Pro.
iPhoneUtils.Vibrate() does vibrate for a long time on iOS and Android too.
Where iOS doesn’t expose a method to do smaller (shorter) vibrations, Android has the ability of vibrate() for a given number of milliseconds and also, play “patterns” of vibrations like morse code, or other combination in patterns with PlayPattern().
Add cool force feedback through the device vibrator in your game or app now !
Tired of having just a half a second vibration ?
Try this and make morse code / rythms / light or heavy rumbles / any kind of vibration you may imagine with VibratePattern () !
Docs:
For initialization:
Vibrator vibration;
void Start()
{
// Startup vibration Java object
vibration = new Vibrator();
vibration.Init();
}
To invoke it:
from anywhere:
vibration.Vibrate ( (long) duration ); // make it vibrate for duration milliseconds
vibration.VibratePattern ( (long) pattern[], (int)repeat_index); // play a pattern defined in the pattern[] array with ability of looping it at a given index)
vibration.Cancel(); // stop the current vibration or vibration pattern loop (it stops also an eventual iPhoneUtils.Vibrate() call)
vibration.Dispose(); // Used in OnApplicationQuit stops the vibration and destroy the library class.
Enjoy !