Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Gamepad Vibration

Discussion in 'Scripting' started by unity_rLrstvXScQEvow, Aug 14, 2019.

  1. unity_rLrstvXScQEvow

    unity_rLrstvXScQEvow

    Joined:
    Mar 4, 2019
    Posts:
    28
    Hello,
    I'm looking for a way to make the controller vibrating by certain actions in game.
    My question is: How can i access the used controller and make it vibrating?

    I've seen a lot of tutorials and forum posts for mobile devices, but could not found something for contrllers like xbox or ps4. Unity manual does not cover this topic as well.
     
  2. alexeu

    alexeu

    Joined:
    Jan 24, 2016
    Posts:
    257
    hi,
    if you're using XInputDotNetPure try this
    Code (CSharp):
    1. GamePad.SetVibration(playerIndex, state.Triggers.Left, state.Triggers.Right);
    2.  
    state.Triggers.Left & state.Triggers.Right could be replaced by other floats
     
  3. unity_rLrstvXScQEvow

    unity_rLrstvXScQEvow

    Joined:
    Mar 4, 2019
    Posts:
    28
    Is XInputDotNetPure a Plug-in? Or is this already implemented in Unity
     
  4. alexeu

    alexeu

    Joined:
    Jan 24, 2016
    Posts:
    257
  5. dkaraush

    dkaraush

    Joined:
    Jan 21, 2017
    Posts:
    2
    XInputDotNetPure is using XInput for Windows-only. What about macOS, is if impossible without native code for it?
    I have Dualshock 4 gamepad connected to macOS and it works great, but there is no way to vibrate it :/