Input system multiplayer detecting same input for both players and multiple issues

Hello there!

This is my first time commenting on a Unity forum so Im deeply sorry if I didn’t ask my question in the best possible way or if I provided very little or very much documentation about my problem, and normally I don’t ask for help unless Im truly desperate about it

Im trying to make a multiplayer top down shooter with local multiplayer. However, one of the requirements is to use the new Input system. We built the controller we actually wanted with the new input system, however, when trying to implement a multiplayer solution using a keyboard and a gamepad… We are able to instantiate both players, however, both receive the same input. For example, if I press WASD on my keyboard, both players will move even if the instantiated player has a Gamepad scheme and the same problem occurs with Gamepad.

Also, we cannot make the gamepad to work on a certain situation. For example, because our game is a top down shooter, we need for the gamepad to be able to rotate and aim using the right stick. However, when we try to move it, its simply not happening and we don’t understand why as we believe its set up correctly. Even when the mouse position action has its own binding for gamepad, the only way the computer is detecting this mouse movement is with… well, the mouse lol.

    void Update()
    {
        mousePosition = inputManager.GetMousePosition();
        targetDirection = mouseWorldPosition - transform.position;

        groundedPlayer = controller.isGrounded;
        if (groundedPlayer && playerVelocity.y < 0)
        {
            playerVelocity.y = 0f;
        }
        Vector2 movement = inputManager.GetPlayerMovement();
        Vector3 move = new Vector3(movement.x, 0, movement.y);
        move.y = 0f;
        controller.Move(move * Time.deltaTime * playerSpeed);

        // Changes the height position of the player..
        if (inputManager.PlayerJumpedThisFrame() && groundedPlayer)
        {
            playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
        }

        playerVelocity.y += gravityValue * Time.deltaTime;
        controller.Move(playerVelocity * Time.deltaTime);
      
        transform.LookAt(new Vector3(mousePosition.x -960, 0f, mousePosition.y - 540));
        Vector3 cameraPos = new Vector3(transform.position.x, transform.position.y + 15, transform.position.z - 10);
        main.transform.position = cameraPos;

    }

Or in this case in regard to the shooting option, it only works with the gamepad and not with the left mouse click for some reason:

   private void Start()
    {
        //Fire
        fire.started += _ => {
            if (!reloading)
            {
                ShootGun();
                playerSpeed = reduceSpeed;
            }             
        };
        fire.canceled += _ => {
            shooting = false;
            playerSpeed = normalSpeed;
        };
        //Abilites
        ability1.canceled += _ => {
            if (!haltActive)
            {
                if (A1)
                    Ability1();
            }
            else
            {
                DetonateHalt();
            }
        };

    }
public void ShootGun()
    {
        shooting = true;
        StartCoroutine("Shooting");
    }

    IEnumerator Shooting()
    {
        while (shooting)
        {
            mousePosition = inputManager.GetMousePosition();
            mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
            if (ammo > 0 )
            {
                RaycastHit hit;
                if (Physics.Raycast(transform.position, transform.forward, out hit, 200f, enemyLayer))
                {
                    Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.green, 2f);

                    if (hit.collider.tag == "Enemy")
                    {
                        if (!supercharged)
                        {
                            //hit.collider.GetComponent<Health>().ReduceHealth(damage);
                        }
                        else
                        {
                           // hit.collider.GetComponent<Health>().ReduceHealth(damage*1.5f);
                        }
                    }
                }
                else
                {
                    Debug.DrawRay(transform.position, transform.forward * 50, Color.red, 3f);
                }
                ammo--;
                gm.TakeAmmo(ammo, stockAmmo);
                yield return new WaitForSeconds(fireRate);                           
            }
            else
            {
                StartCoroutine("Reload");
                break;
            }

        }

    }

    IEnumerator Reload()
    {
        //Player cannot reload without stock ammo
        if (stockAmmo > 0)
        {
            reloading = true;
            yield return new WaitForSeconds(reloadTime);
            float tempAmmo = 150f - ammo;
            if (stockAmmo >= tempAmmo)
            {
                ammo = roundAmmo;
                stockAmmo -= tempAmmo;
            }
            else
            {
                ammo = stockAmmo + ammo;
                stockAmmo = 0f;
            }
            gm.TakeAmmo(ammo, stockAmmo);
            reloading = false;
        }
        else
        {
            reloading = false;
        }

Any input or help would be really appreciated.

CODE FOR CONTROLLER (complete version)

using System.Collections;
using UnityEngine;
using UnityEngine.InputSystem;

[RequireComponent(typeof(CharacterController), typeof(PlayerInput), typeof(Health))]
public class PlayerController : MonoBehaviour
{
    #region Variables
    //Every Variable regarding to movement
    [SerializeField]
    private float playerSpeed = 5.0f, jumpHeight = 1.0f, gravityValue = -9.81f, playerHP = 200, playerShield = 250, protectiveBarrierHP = 600,
        ammo = 150, stockAmmo = 300, roundAmmo, haltRadius = 5f, fireRate = 0.083f, reloadTime = 2.55f, damage = 11,
        rotationSpeed = 10f, clampAngle = 80f,
        cooldown1 = 6f, cooldown2 = 10f, cooldown3 = 11f, cooldown4 = 15f;
    //Layer Mask for raycast
    [SerializeField] LayerMask enemyLayer, environmentLayer;
    //Hit UI
    [SerializeField] GameObject haltPrefab, protectiveBarrierPrefab, superchargerPrefab;
    //Transforms
    [SerializeField] private Transform weaponTransform, barrelTransform;
    #endregion

    #region Constants
    private bool groundedPlayer, shooting, reloading, haltActive, A1 = true, A2 = true, A3 = true, U = true;
    public bool supercharged = false;
    private float normalSpeed, reduceSpeed;
    private CharacterController controller;
    private PlayerInput playerInput;
    private Vector3 playerVelocity, weaponRotation, targetDirection, mouseWorldPosition;
    private Vector2 mousePosition;
    private InputManager inputManager;
    private GameObject haltProjectile;
    private GameManager gm;
    private Health health;
    private Camera main;

    //Every Input Action
    private InputAction fire, ability1, reload;
    #endregion

    private void Awake()
    {
        //Get components
        controller = GetComponent<CharacterController>();
        inputManager = InputManager.Instance;
        playerInput = GetComponent<PlayerInput>();
        gm = FindObjectOfType<GameManager>();
        health = GetComponent<Health>();
        main = GetComponent<PlayerInput>().camera;
        //health.SetHealth(playerHP, playerShield, true);
        roundAmmo = ammo;
        haltActive = false;
        A1 = true;
        A2 = true;
        A3 = true;
        gm.SetAmmo(ammo, stockAmmo);
        if (weaponRotation == null)
        {
            weaponRotation = weaponTransform.localRotation.eulerAngles;
        }
        reduceSpeed = playerSpeed * 1 / 3;
        normalSpeed = playerSpeed;

    
        //Assign Input Actions
        //Shooting
        fire = playerInput.actions["Fire"];
        reload = playerInput.actions["Reload"];
        //Abilities     
        ability1 = playerInput.actions["Ability1"];
    }

    #region NewInputSystem
    private void Start()
    {
        //Fire
        fire.started += _ => {
            if (!reloading)
            {
                ShootGun();
                playerSpeed = reduceSpeed;
            }             
        };
        fire.canceled += _ => {
            shooting = false;
            playerSpeed = normalSpeed;
        };
        //Abilites
        ability1.canceled += _ => {
            if (!haltActive)
            {
                if (A1)
                    Ability1();
            }
            else
            {
                DetonateHalt();
            }
        };

    }

    private void OnEnable()
    {
        fire.Enable();
        reload.Enable();
        ability1.Enable();
    }

    private void OnDisable()
    {
        fire.Disable();
        reload.Disable();
        ability1.Disable();
    }
    #endregion
    #region Movement
    void Update()
    {
        mousePosition = inputManager.GetMousePosition();
        targetDirection = mouseWorldPosition - transform.position;

        groundedPlayer = controller.isGrounded;
        if (groundedPlayer && playerVelocity.y < 0)
        {
            playerVelocity.y = 0f;
        }
        Vector2 movement = inputManager.GetPlayerMovement();
        Vector3 move = new Vector3(movement.x, 0, movement.y);
        move.y = 0f;
        controller.Move(move * Time.deltaTime * playerSpeed);

        // Changes the height position of the player..
        if (inputManager.PlayerJumpedThisFrame() && groundedPlayer)
        {
            playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
        }

        playerVelocity.y += gravityValue * Time.deltaTime;
        controller.Move(playerVelocity * Time.deltaTime);
      
        transform.LookAt(new Vector3(mousePosition.x -960, 0f, mousePosition.y - 540));
        Vector3 cameraPos = new Vector3(transform.position.x, transform.position.y + 15, transform.position.z - 10);
        main.transform.position = cameraPos;

    }
    #endregion
    #region ShootingBasics
    public void ShootGun()
    {
        shooting = true;
        StartCoroutine("Shooting");
    }

    IEnumerator Shooting()
    {
        while (shooting)
        {
            mousePosition = inputManager.GetMousePosition();
            mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
            if (ammo > 0 )
            {
                RaycastHit hit;
                if (Physics.Raycast(transform.position, transform.forward, out hit, 200f, enemyLayer))
                {
                    Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.green, 2f);

                    if (hit.collider.tag == "Enemy")
                    {
                        if (!supercharged)
                        {
                            //hit.collider.GetComponent<Health>().ReduceHealth(damage);
                        }
                        else
                        {
                           // hit.collider.GetComponent<Health>().ReduceHealth(damage*1.5f);
                        }
                    }
                }
                else
                {
                    Debug.DrawRay(transform.position, transform.forward * 50, Color.red, 3f);
                }
                ammo--;
                gm.TakeAmmo(ammo, stockAmmo);
                yield return new WaitForSeconds(fireRate);                           
            }
            else
            {
                StartCoroutine("Reload");
                break;
            }

        }

    }

    IEnumerator Reload()
    {
        //Player cannot reload without stock ammo
        if (stockAmmo > 0)
        {
            reloading = true;
            yield return new WaitForSeconds(reloadTime);
            float tempAmmo = 150f - ammo;
            if (stockAmmo >= tempAmmo)
            {
                ammo = roundAmmo;
                stockAmmo -= tempAmmo;
            }
            else
            {
                ammo = stockAmmo + ammo;
                stockAmmo = 0f;
            }
            gm.TakeAmmo(ammo, stockAmmo);
            reloading = false;
        }
        else
        {
            reloading = false;
        }

    }

Also, this is how my PlayerManager is set up:

These are some errors that happen when I click on play and join in using my Dualshock 4 (notice that it instantiates two players at once instead of one by one) :

And these are the errors that occur when joining using my Keyboard (it spawned one at the time):

Again, any help will be appreciated as Im really desperate :confused:

Cheers and happy weekend!

I would recommend setting this project aside and go find a nice multiplayer new input system tutorial and work through it until you have two inputs going perfectly.

Once you have that you can open your original project above and compare side-by-side, or maybe it will already occur to you the steps missing.