[SOLVED] Need help with local multiplayer

Hi, I am currently making a game, a Tetris-like in 3D, and I try the new Input System on it.
In my game each player play one after an another.

I want to know if there is a way to listen inputs only from one specific device, this way I could associate a player with an device and mute all others when it his turn. Or just listen to a specific device.

I use event callback for every Press action, and Action.ReadValue() for axis input in Update.

I think PlayerInputManager is not usefull here since I don’t have several object to control.

I dont believe there is a way to mute input for devices, but you can stop your scripts from listening for input.

One way to do this would be for each player to have a simple state machine. You really only need 2 states: the MyTurn state and the NotMyTurn state. The MyTurn state subscribes or listens for inputs, and feeds those inputs into whatever game mechanic you need. Then, when finished, the TurnState unsubscribes from inputs and then transitions into the NotMyTurn state. The NotMyTurn state is basically empty, listens for no inputs, and does nothing.

I change the way my scripts work.
I now have a prefab with a PlayerInput and a the following script :

public class PlayerInputs : MonoBehaviour
{
    Controls controls;

    public Vector2 movementDirection;
    public Vector2 cameraMovementPad;
    public Vector2 cameraMovementMouse;
    public float up;
    public float down;
    public bool cameraCanMove;

    private void Awake()
    {
        controls = new Controls();

        controls.Gameplay.Move.performed += ctx => movementDirection = ctx.ReadValue<Vector2>();
        controls.Gameplay.Move.canceled += ctx => movementDirection = Vector2.zero;

        controls.Gameplay.CameraMovementPad.performed += ctx => cameraMovementPad = ctx.ReadValue<Vector2>();
        controls.Gameplay.CameraMovementPad.canceled += ctx => cameraMovementPad = Vector2.zero;

        controls.Gameplay.CameraMovementMouse.performed += ctx => cameraMovementMouse = ctx.ReadValue<Vector2>();
        controls.Gameplay.CameraMovementMouse.canceled += ctx => cameraMovementMouse = Vector2.zero;

        controls.Gameplay.Up.performed += ctx => up = ctx.ReadValue<float>();
        controls.Gameplay.Up.canceled += ctx => up = 0;

        controls.Gameplay.Down.performed += ctx => down = ctx.ReadValue<float>();
        controls.Gameplay.Down.canceled += ctx => down = 0;

        controls.Gameplay.CameraCanMove.started += ctx => cameraCanMove = true;
        controls.Gameplay.CameraCanMove.canceled += ctx => cameraCanMove = false;

        controls.Gameplay.RotX.started += ctx => RotX();
        controls.Gameplay.RotY.started += ctx => RotY();
        controls.Gameplay.RotZ.started += ctx => RotZ();
        controls.Gameplay.Drop.started += ctx => Drop();
        controls.Gameplay.Restart.started += ctx => Restart();
        controls.Gameplay.SwitchMovementSystem.started += ctx => SwitchMovementSystem();
    }

    private void OnEnable()
    {
        controls.Gameplay.Enable();
    }
    private void OnDisable()
    {
        controls.Gameplay.Disable();
    }

    private void Update()
    {
        GameManager.instance.movementDirection = movementDirection;
        GameManager.instance.cameraMovementPad = cameraMovementPad;
        GameManager.instance.cameraMovementMouse = cameraMovementMouse;
        GameManager.instance.up = up;
        GameManager.instance.down = down;
        GameManager.instance.cameraCanMove = cameraCanMove;
    }

    void RotX()
    {
        GameManager.instance.movingScript.RotX();
    }

    void RotY()
    {
        GameManager.instance.movingScript.RotY();
    }

    void RotZ()
    {
        GameManager.instance.movingScript.RotZ();
    }

    void Drop()
    {
        GameManager.instance.movingScript.Drop();
    }

    void Restart()
    {
        GameManager.instance.Restart();
    }

    void SwitchMovementSystem()
    {
        GameManager.instance.movingScript.SwitchMovementSystem();
    }
}

But when I try to use PlayerInputManager to spawn this prefab the devices are not paired with the prefab it just spawns. When I press a button on one device it does the call on both of the prefabs… I must miss something, I think it’s the fact that I use directly my map (Controls.Gameplay) but I am not sure since this is not the same instance of the map on the two PlayerInput.

Okay, looks like this method doesn’t work for multiplayer, so I change and only use messages send by the PlayerInput component and it works.