Unity 3D Game Engine – How to make an android device vibrate

1. Hierarchy> Main Camera> attach the script ‘Vibrate.js’

Vibrate.js

1
2
3
4
5
6
7
8
9
10
function Update () {
    
}
 
// Press button to vibrate START
function OnGUI () {
    if (GUI.Button (Rect (0, 10, 100, 32), "Vibrate!"))
    Handheld.Vibrate ();
}
// Press button to vibrate END