Search Unity

[HELP] Setting up Local Multiplayer issues...

Discussion in 'Input System' started by Sergiodela, Feb 6, 2020.

  1. Sergiodela

    Sergiodela

    Joined:
    Jan 19, 2019
    Posts:
    3
    Hi,

    As I didnt find official documentation, Im going to ask here a few questions:

    About the Player Input Manager Component:

    - in the parameter "Join Behaviour", the choice "Join Players Manually" how does it work? How can I join players manually?

    -Input Manager does only support an unique prefab to be instantiated? Because in my particular game, each player selects a different character so I would need instead of only 1 Gameobject parameter called PlayerPrefab, a list of PlayerPrefabs to choose which one I want to instantiate each time a new player joins.

    About the Player Input Component:

    - Is there any way to know the current Gamepad's index used by each player of my local multiplayer game via Gamepad.current.<anyproperty>? I would like to check this in each PlayerController script of all the active playable characters being controlled by each player.
     
    Last edited: Feb 6, 2020
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    You can join players manually by calling one of the PlayerInputManager.JoinPlayer() methods or by just calling PlayerInput.Instantiate() methods directly (in the latter case, you don't really need PlayerInputManager except if you want its split-screen support).

    Yeah, this is currently still pretty weak. PlayerInputManager should allow more control over the spawning process of players. It's on the list.

    Code (CSharp):
    1. var playerForGamepad0 = PlayerInput.FindFirstPairedToDevice(Gamepad.all[0]);
     
    ETGgames likes this.
  3. Sergiodela

    Sergiodela

    Joined:
    Jan 19, 2019
    Posts:
    3
    Appreciate your response... Thanks!
     
    nepeters092 likes this.
  4. AHWilliams

    AHWilliams

    Joined:
    Jan 11, 2014
    Posts:
    10
    You could also just have a player prefab that is a player controller with references to the other prefabs. Once it is instantiated it would create the character prefab the player chooses as a child object. Alternatively it could contain all the characters and just turn them on/off as needed.
     
  5. Sergiodela

    Sergiodela

    Joined:
    Jan 19, 2019
    Posts:
    3
    Thanks for your answer.
    I knew there were alternatives to make it work for sure but I just wanted to ask if there were direct support to this feature because it's a basic one for local multiplayer games.