I am currently trying to get controller rumble to work in my game. I have downloaded a package with a script that when the left or right trigger is pressed the controller vibrates. Code (CSharp): using UnityEngine; using XInputDotNetPure; // Required in C# public class XInputTestCS4 : MonoBehaviour { bool playerIndexSet = false; PlayerIndex playerIndex; GamePadState state; GamePadState prevState; // Use this for initialization void Start() { // No need to initialize anything for the plugin } void FixedUpdate() { // SetVibration should be sent in a slower rate. // Set vibration according to triggers GamePad.SetVibration(playerIndex, state.Triggers.Left, state.Triggers.Right); // The line of interest } // Update is called once per frame void Update() { // Find a PlayerIndex, for a single player game // Will find the first controller that is connected ans use it if (!playerIndexSet || !prevState.IsConnected) { for (int i = 0; i < 4; ++i) { PlayerIndex testPlayerIndex = (PlayerIndex)i; GamePadState testState = GamePad.GetState(testPlayerIndex); if (testState.IsConnected) { Debug.Log(string.Format("GamePad found {0}", testPlayerIndex)); playerIndex = testPlayerIndex; playerIndexSet = true; } } } prevState = state; state = GamePad.GetState(playerIndex); } } Changed Code Code (CSharp): { // SetVibration should be sent in a slower rate. // Set vibration according to triggers GamePad.SetVibration(playerIndex, state.Triggers.Right); //The line of interest } As you can see, I have removed the left trigger vibration and I get error CS7036: There is no argument that corresponds to the required formal parameter 'rightMotor of'GamePad.SetVibration(PlayerIndex, float, float)' Can someone help navigate through the jargon to fix this problem.
Hey @ChamberGames. I am pretty new to input system but honestly I don't think your issue is input system related. It might just be the problem with method signature or rather how you call it. If you using VisualStudio or have properly configured VSCode editor CTRL click (or CMD click if on mac) to step into the method. I suspect method takes 3 arguments and you are calling it with 2. If that's the case you could try Code (CSharp): GamePad.SetVibration(playerIndex, null, state.Triggers.Right); That would ensure you are calling it as it was defined in the example.
I inserted the code but now I am getting error CS1503: Argument 2: cannot convert from '<null>' to 'float'
Well... Following the message I would suggest replacing null with 0 then. Code (CSharp): GamePad.SetVibration(playerIndex, 0, state.Triggers.Right);