- Home /
Vibrate for X time on iOS?
Hey guys,
Does anyone know the way to make the phone vibrate for a desired amount of time? Handheld.Vibrate()
doesn't cut it as it doesn't have a time parameter and the phone always vibrates for a set amount of time and I can't seem to find any plugins on the asset store.
If anyone knows the plugin or any other way I could do it, I'd appreciate it.
Thanks!
Looking for the same thing. Is there anything new since this question was posted?
Answer by alok-kr-029 · Mar 09, 2015 at 11:13 AM
void Start()
{
StartCoroutine("vib");
}
IEnumerator vib()
{
Handheld.Vibrate();
yield return new WaitForSeconds (.25f);
Handheld.Vibrate();
yield return new WaitForSeconds (.25f);
Handheld.Vibrate();
yield return new WaitForSeconds (.25f);
Handheld.Vibrate();
yield return new WaitForSeconds (.25f);
Handheld.Vibrate();
}
this will make your phone vibrate for 1 sec as after every .25 sec I am calling Handheld.Vibrate(); you can also use loop instead of calling it like this if you have long time period.
I may not have been clear with my question. I need to Vibrate for a specific amount of time, for example Vibrate(0.1f), Vibrate(0.25f), etc.
http://nikprogram$$anonymous$$g.blogspot.in/2012/10/android-vibration-support-in-unity3d.html
http://answers.unity3d.com/questions/350193/handheldvibrate-duration.html
I found those links before I posted this and they yielded nothing. I don't know Objective C and don't have time to invest in it right now, so I was looking for an existing plugin