I don’t really need a 1 second vibration for every touch. Is there any way of controlling the duration here?
if (Application.platform != RuntimePlatform.Android) return;
AndroidJavaClass unity= new AndroidJavaClass(“com.unity3d.player.UnityPlayer”);
AndroidJavaObject ca = unity.GetStatic(“currentActivity”);
AndroidJavaClass vibratorClass = new AndroidJavaClass(“android.os.Vibrator”);
AndroidJavaObject vibratorService = ca.Call(“getSystemService”,ca.GetStatic(“VIBRATOR_SERVICE”));
vibratorService.Call("vibrate", (long)timeInMilliseconds);
unity.Dispose();
ca.Dispose();
vibratorClass.Dispose();
vibratorService.Dispose();
remember to add permission for vibration to manifest and check ur device vibrates.
youre welcome.
I’ve been searching for the past month. All I found was this simple, cheap and functioning plugin for Android which lets you vibrate for a specific duration.
The bad part is that Handheld.Vibrate doesn’t seem to be working at all for Windows Phone.