Search Unity

Question Limiting controls to for example ONLY gamepad and not allowing keyboard/mouse input

Discussion in 'Input System' started by potatomasterrace, Mar 6, 2023.

  1. potatomasterrace

    potatomasterrace

    Joined:
    May 23, 2019
    Posts:
    70
    I have the following control schemes:


    Now say I want ONLY gamepad controls to register, I do not want keyboard or mouse to have any effect, so I set the control scheme in code like this:

    playerInput.SwitchCurrentControlScheme("Gamepad",Gamepad.all[0]);

    I also log every update what the current control scheme is and initially it successfully shows as "Gamepad". However the instant I press the mouse or keyboard, suddenly the control scheme changes to my other control scheme "KeyboardMouseGamepad". Why does it automatically do this?

    This problem is the first step towards introducing local multiplayer where each player should only be getting inputs from 1 device. But the first step is obviously being able to restrict inputs for a particular playerinput to only 1 device. What am I doing wrong?

    Any advice much appreciated.

    edit: think i finally found it:

    playerInput.neverAutoSwitchControlSchemes = true;
     
    Last edited: Mar 7, 2023
    RaL likes this.