Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to vibrate a phone continuously?

Discussion in 'Scripting' started by tomang5, Jul 8, 2020.

  1. tomang5

    tomang5

    Joined:
    Feb 18, 2020
    Posts:
    63
    Hi all,

    Is there a way to vibrate a user's phone depending on a state in the game? For example, if the car that the player's controlling goes off the road, I'd like to vibrate the phone until the player returns back to the road. How can I do that?

    Also, I want to ask if it is a good UX? I'd like to hear you guys' opinions about this.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I believe all Unity has built in is Handheld.Vibrate
    https://docs.unity3d.com/ScriptReference/Handheld.Vibrate.html

    Though a quick google search turned up this to give more control with native Android calls
    https://gist.github.com/aVolpe/707c8cf46b1bb8dfb363

    But I'd include an option in your game to disable vibration, as I'd expect it will piss a bunch of people off. Nothing worse than playing a game in line at the DMV or in bed while your significant other is asleep, and having your phone just constantly vibrating (which on some devices can be quite loud).
     
    tomang5 likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,798
    I can't stand vibration in my hand or controller. I used to go hunting to turn it off, now if a game vibrates even once for me, I just exit and immediately delete the game. Life is far too short for irritations like digging through someone's menus hoping they put an option in. DELETE.
     
    tomang5 and Joe-Censored like this.
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    It's a phone, not a rumble controller. I'd find it annoying.
     
    tomang5 and Joe-Censored like this.
  5. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,064
    IMHO don't re-create rumble controller features on a phone.
    It drains the battery of the phone and it can possibly be an annoying experience to players. Some phones have really loud vibrations for instance.

    If a controller is connected to the phone you can use the controller's vibration functions. But I wouldn't do this with the phone itself. But if it were a huge requested feature I'd still make it optional and by default off.
     
    Joe-Censored and tomang5 like this.
  6. Thibault-Potier

    Thibault-Potier

    Joined:
    Apr 10, 2015
    Posts:
    206
    This is rather intense ^^ I would put it it in the options, along with "disable sound" or "disable music". This is similar feature : an extra feedback that can become irritable if the user want to play silently

    And you don't have to "bury" it deep inside the UI : most of game just put those options clearly on the main screen
     
    tomang5 likes this.
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,798
    This has not been my experience. Most software is dreadfully laid out, and I don't exempt my own software from that either. I try to do well, but it's hard to imagine into the future how another human you've never met will understand your UI and menus.
     
    Joe-Censored and tomang5 like this.
  8. tomang5

    tomang5

    Joined:
    Feb 18, 2020
    Posts:
    63
    Thank you for the answers.

    I think, I won't implement that feature. It looks like annoying according to your opinions :)
     
    Joe-Censored likes this.
  9. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    I loved rumble in controllers, really annoys me that plugging my gamecube controlers into usb doesnt give me access to the rumble on emulators