- Home /
Handheld.Vibrate() not working
I want to make my phone vibrate when two objects collide (2d game), so i tried this:
using UnityEngine; using System.Collections;
public class Vibrate : MonoBehaviour {
void OnCollisionEnter2D(Collision2D collision){
if(collision.gameObject.tag=="myTag"){
Handheld.Vibrate();
}
}
}
but it is not working.
try
if(collision.gameObject.tag=="myTag")
{
print("vibrate now");
Handheld.Vibrate();
}
see if you get that print first then move forwrd
Answer by KemoM · Jun 22, 2015 at 02:10 PM
Found a solution - so, if anyone has the same problem as I had here goes:
you need to build and run, or make an apk file and it will work. Unity Remote doesn't allow vibrate if you just press play.
also - game doesn't look as good on the mobile if you just press play, but if you click build and run it will look the way it should.
Basically, it is a Unity Remote issue.
You didn't even say that you're testing with the Unity remote app. This app (Unity Remote) is nothing but a remote control for the editor. The game actually plays in the editor. The app just routes input from the device to the editor and transfers a video stream to the device which is displayed there.
You should read the docs on the remote app. Also note the "Troubleshooting" section at the bottom.
When using Unity Remote you also can't use native plugins since you don't actually run your application on the device. As said it's just a remote control for the editor. You can only use things the remote app supports.
Forgot to mention I was testing it using Unity Remote, this is my first game and I'm still trying to find my way around :)
Answer by StroBerri · Jul 21, 2021 at 09:34 AM
I have that problem. Tho the solution in mine was I changed the void from private to public or just void.