Search Unity

Local Multiplayer, Assigning Unused devices to handles

Discussion in 'Input System' started by Xeno10001110101, Apr 13, 2016.

  1. Xeno10001110101

    Xeno10001110101

    Joined:
    Jul 3, 2015
    Posts:
    1
    Evening all, Question regarding multiplayer assignments to handles,

    I have the basics down, got my controllers working off the bat, much more intuitive than previously and it worked first attempt! I'm currently building a game that's planned to have >20 players local versus for a LAN party in the next few weeks.

    My question comes from the documentation where I can't quite grasp what I have to do to assign unused controllers to players, I'm using the player handles during startup of my players but can't figure out a way to assign controllers/inputs to any of them.

    If anyone could help, either by pointing me to some documentation or a straight answer, it'd be much appreciated!
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Hi!

    The video explains a multiplayer setup at a high level. For details have a look at the MultiplayerManager.cs example script that comes as part of the demo and is used for the multiplayer scene.

    In that script, players can join the game by pressing a dedicated join button, then press a button to indicate they're ready. When all joined players are ready, the game begins.

    This is just an example; there are many different ways multiplayer can be handled.

    Does that help? Let me know if you have further questions.
     
  3. JeeshusChrist

    JeeshusChrist

    Joined:
    May 14, 2016
    Posts:
    3
    I'm having problems with this currently. I was working on a drop in and out at anytime system that spawns the prefab that is used within the MultiplayerManager.cs. That spawned instance allows players to select their character type, then once selected it will spawn an actual character. The problem is once I spawn that prefab from MultiplayerManager the global stops listening to inputs from other devices, even though it is still active. They both are using the same action map, but based on how MultiplayerManager is written, the prefab has to use the same scheme.

    When I switched to purely the MultiplayerManager without drop in and out at anytime, when I have more than one player join the game and the game starts I get this error:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.InputNew.ActionMapInput.ExtractCurrentValuesFromSources () (at Assets/input-prototype/Input/ActionMapInput.cs:271)
    UnityEngine.InputNew.ActionMapInput.Reset (Boolean initToDeviceState) (at Assets/input-prototype/Input/ActionMapInput.cs:224)
    UnityEngine.InputNew.ActionMapInput.set_active (Boolean value) (at Assets/input-prototype/Input/ActionMapInput.cs:45)
    UnityEngine.InputNew.PlayerInput.Awake () (at Assets/input-prototype/Input/PlayerInput.cs:29)
    UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
    MultiplayerManager:StartGame() (at Assets/Demo/Scripts/MultiplayerManager.cs:171)
    MultiplayerManager:Update() (at Assets/Demo/Scripts/MultiplayerManager.cs:121)

    Any help would be appreciated!
     
  4. JeeshusChrist

    JeeshusChrist

    Joined:
    May 14, 2016
    Posts:
    3
    Issues have been resolved. The error came from accidentally having the prefab objects PlayerInput have auto assign global. This also tied into having the original global not pick up any more after one joined.
     
    runevision likes this.
  5. Kade514

    Kade514

    Joined:
    Sep 7, 2014
    Posts:
    12
    Hi,
    I'm having a similar issue with my local multiplayer game, however in my case, I have a global handle whose controller is unassigned at the end of a level as part of a general reset function and as a result, when the player returns to the main menu from the game level they're unable to navigate it using a gamepad and so get stuck. I've tried to repurpose the code used in the MultiplayerManager script to resolve this issue, however, I find it difficult to understand and was just wondering if there's a simpler way to assign a controller to a handle?