Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

How to Vibrate?

Discussion in 'Input System' started by io-games, Oct 14, 2019.

  1. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    104
    Hi!

    Is there any method for vibrating?

    I'm interested in ds4, switch.
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Code (CSharp):
    1. gamepad.SetMotorSpeeds(0.123f, 0.234f);
     
    io-games likes this.
  3. crocvr

    crocvr

    Joined:
    Oct 7, 2015
    Posts:
    44
    Is it applicable for htc vive joysticks?
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    The Vive controller has a different haptics interface.

    Code (CSharp):
    1. viveController.SendImpulse(amplitude, duration);
     
    io-games likes this.
  5. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    does it working on PS4 and XB one consoles?
    and what about android vibration?
     
  6. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Mmmh, maybe I'm really unlucky, but wtf xD

    I just added this line into my GameManager Awake():

    Gamepad.current.SetMotorSpeed(0.1f, 0.8f)

    Just to try. It didn't stopped vibrating after like 3-4 seconds so I panicked a bit and unplugged my controller. My pc froze I had to force shutdown.

    Has this happened to anyone ?
     
  7. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Yes.

    No rumble support (yet? from all I know Android is making this one quite tricky).
     
  8. Davood_Kharmanzar

    Davood_Kharmanzar

    Joined:
    Sep 20, 2017
    Posts:
    411
    awesome :]
     
  9. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    I cant get Xbox one controller to rumble on pc. Do you have to have it setup as an xbox controller in control schemes or should it also work as a gamepad?

    edit: my batteries were low. It works now:oops:
     
    Last edited: Oct 26, 2019
  10. windwoes

    windwoes

    Joined:
    Sep 19, 2021
    Posts:
    1
    For reasons completely unrelated to Unity for Android, I've written an Android userspace USB driver for PS4 and Xbox360 protocol-compatible gamepads (though, adding support for other protocols probably wouldn't be too hard with a known specification for the packet structure). This allows complete control over the controller regardless of Android device model or Android version, enabling use of features not supported by the Android InputDevice stack / Linux kernel driver. Namely, controlling the rumble motors and LEDs on these gamepads, as well as reading the unique serial number (perhaps useful for storing a per-controller calibration).

    I have no experience with Unity, so I'm not sure whether this is something that app devs could easily bolt onto their apps and make use of, or whether it would need to be added to the (closed source?) unity core. Happy to discuss if there's any interest.
     
  11. angelonit

    angelonit

    Joined:
    Mar 5, 2013
    Posts:
    40
    The name 'gamepad' does not exist in the current context

    Do I need any special packages for this?
    ______________________
    Edited because I found it (I hadn't seen this forum was under Input System since I got here from a google search):
    1- You have to install the "Input System" (the new one from unity), I did it via package manager
    2- Then go to "Project settings" --> "Player" --> "Other Settings" --> "Configuration"
    3- Set the option called "Active Input Handling" to "Input System Package (new)" or "Both"
    4- Finally in your Script you have to include "using UnityEngine.InputSystem;" at the top.
     
    Last edited: Feb 7, 2023
    Prajwal_0 and pandacraftguy like this.
  12. Lughinu

    Lughinu

    Joined:
    Nov 3, 2016
    Posts:
    11
    new API:
    Gamepad.current.SetMotorSpeeds(0.123f, 0.234f);
     
    CiroContns likes this.
  13. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    629
    I read in the docs that the Switch Controller Rumble is not yet supported in the Editor, but will it work if we release the game on steam and someone is playing with a switch controller via their laptop?

    I would also like to know if editor support for the switch controller is coming - right now I'm lending a ps4 controller from a friend but it's definitely not a long-term solution :')

    Edit:
    I should mention I have a switch dev-kit: I know the NDA doesn’t allow to go into detail, but is it at least possible to support switch rumble using it? At least then I won’t go on a witch hunt for it.
     
    Last edited: Mar 2, 2023
  14. joelprogrammer

    joelprogrammer

    Joined:
    Oct 15, 2020
    Posts:
    7
    Hi, I managed to vibrate my controller with Gamepad.current.setMotorspeeds() but I don't know how to vibrate my t248 thrusmater steering wheel.
    Can you help me?
     
  15. Liderangel

    Liderangel

    Joined:
    Jul 8, 2018
    Posts:
    101

    Hey, I'm from 4 years into the future. Is there rumble support for phones now?
     
    HouinKyouma27 likes this.