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.
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.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
{
// SetVibration should be sent in a slower rate.
// Set vibration according to triggers
GamePad.SetVibration(playerIndex, state.Triggers.Left, state.Triggers.Right);
}
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.