Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

New Input System: Configure rumble on a specific gamepad?

Discussion in 'Scripting' started by JamesDonald, Jun 5, 2020.

  1. JamesDonald

    JamesDonald

    Joined:
    Oct 12, 2018
    Posts:
    4
    Hi there,

    I have just been reading through the documentation on the new Input System 1.0 and have started implementing it into my local multiplayer project. I noticed that there is a way to set the motor speeds using :

    Gamepad.current.SetMotorSpeeds(low freq, high freq);

    As I am using multiple gamepads I am wanting to single out a specific gamepad related to that player and only produce rumble for that gamepad. When I use the above, it produces rumble on all connected gamepads.

    Apologies if ive overlooked something, but if anyone could point me in the right direction that would be great.

    Thanks!
     
    Ale_IB likes this.
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    It depends. But something like this:

    Code (CSharp):
    1. // Mark gamepad #2 as being for player 1.
    2. InputSystem.SetDeviceUsage(Gamepad.all[1], "Player1");
    3. // And later look it up.
    4. var player1Gamepad = InputSystem.GetDevice<Gamepad>(new InternedString("Player1"));
    And then you can use the player1Gamepad instead of the Gamepad.current.

    More info and more possibilities here: https://docs.unity3d.com/Packages/c.../api/UnityEngine.InputSystem.InputSystem.html
     
    Radicals270 and JamesDonald like this.
  3. JamesDonald

    JamesDonald

    Joined:
    Oct 12, 2018
    Posts:
    4
    Exactly what ive been looking for, thanks for the help!
     
    Lurking-Ninja likes this.
  4. CubeJaw

    CubeJaw

    Joined:
    Jan 17, 2020
    Posts:
    3
    gamepad = playerInput.GetDevice<Gamepad>();

    this works for local multiplayer