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. Dismiss Notice

Get input from specific gamepad

Discussion in 'Input System' started by MrDasix, May 2, 2020.

  1. MrDasix

    MrDasix

    Joined:
    Feb 15, 2015
    Posts:
    64
    I have an action Map already created, but this action Map responds to all gamepads. How can i make the action map respond to a unique gamepad?
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    I assume you are using "Generate C# Class".

    Code (CSharp):
    1. var inputs = new MyInputs();
    2. inputs.devices = new[] { Gamepad.all[1] };
     
    MrDasix likes this.
  3. MrDasix

    MrDasix

    Joined:
    Feb 15, 2015
    Posts:
    64
    Doing this can i have the same script that controls the input in 2 gameobjects and the script of each gameobject have a diferent device? Or i have to clone something?
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    You can instantiate the generated C# class multiple times and give each instance a separate set of devices.
     
  5. MrDasix

    MrDasix

    Joined:
    Feb 15, 2015
    Posts:
    64
    Thanks! it works!!!!