Search Unity

Question Error CS7036

Discussion in 'Input System' started by ChamberGames, Dec 4, 2022.

  1. ChamberGames

    ChamberGames

    Joined:
    Mar 30, 2022
    Posts:
    10
    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):
    1. using UnityEngine;
    2. using XInputDotNetPure; // Required in C#
    3.  
    4. public class XInputTestCS4 : MonoBehaviour
    5. {
    6.     bool playerIndexSet = false;
    7.     PlayerIndex playerIndex;
    8.     GamePadState state;
    9.     GamePadState prevState;
    10.  
    11.     // Use this for initialization
    12.     void Start()
    13.     {
    14.         // No need to initialize anything for the plugin
    15.     }
    16.  
    17.     void FixedUpdate()
    18.     {
    19.         // SetVibration should be sent in a slower rate.
    20.         // Set vibration according to triggers
    21.         GamePad.SetVibration(playerIndex, state.Triggers.Right); // The line of interest
    22.     }
    23.  
    24.     // Update is called once per frame
    25.     void Update()
    26.     {
    27.         // Find a PlayerIndex, for a single player game
    28.         // Will find the first controller that is connected ans use it
    29.         if (!playerIndexSet || !prevState.IsConnected)
    30.         {
    31.             for (int i = 0; i < 4; ++i)
    32.             {
    33.                 PlayerIndex testPlayerIndex = (PlayerIndex)i;
    34.                 GamePadState testState = GamePad.GetState(testPlayerIndex);
    35.                 if (testState.IsConnected)
    36.                 {
    37.                     Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
    38.                     playerIndex = testPlayerIndex;
    39.                     playerIndexSet = true;
    40.                 }
    41.             }
    42.         }
    43.  
    44.         prevState = state;
    45.         state = GamePad.GetState(playerIndex);
    46.     }
    47. }
    Changed Code
    Code (CSharp):
    1. {
    2.         // SetVibration should be sent in a slower rate.
    3.         // Set vibration according to triggers
    4.         GamePad.SetVibration(playerIndex, state.Triggers.Left, state.Triggers.Right);
    5.     }
    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.
     
  2. IndieForger

    IndieForger

    Joined:
    Dec 31, 2012
    Posts:
    92