Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

PlayerInputManager standard practice

Discussion in 'Input System' started by james7132, Nov 1, 2019.

  1. james7132

    james7132

    Joined:
    Mar 6, 2015
    Posts:
    166
    What's the standard practice when working with PlayerInputManager? Create one for every scene and let it spawn players automatically using the state of the entire InputSystem? or have one set to DontDestroyOnLoad so that it persists from one scene to another? What happens if the PlayerInputs are destroyed by scene load and the manager is not? Equally, what happens if the reverse happens?
     
    Heimlink likes this.
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    I'm thinking that PlayerInputManager probably ended up with a somewhat misleading name (and currently also somewhat fuzzy responsibilities). Maybe should have been called PlayerInputLobby or something like that.

    PlayerInputManager has little impact on PlayerInput other than initiating joins and having some logic to distribute screen real estate for split-screen. So it's fine to only have the manager around while the lobby is open. If players can join at any time, that'd mean for it to stick around but if the lobby is a separate stage before gameplay, it's fine to nuke PlayerInputManager when transitioning away from the lobby.

    PlayerInput is not reliant on PlayerInputManager. It will suppress automatic control scheme switching when there is a manager that has joining enabled but it's fine with there not being a manager (and you can suppress auto-switching manually through PlayerInput.neverAutoSwitchControlSchemes).

    But yeah, overall, think PlayerInputManager == lobby. No need for lobby, no need for PlayerInputManager.
     
    ColinPage likes this.
  3. m4rtin-t

    m4rtin-t

    Joined:
    Jan 30, 2016
    Posts:
    8
    @Rene-Damm Hi I'm looking at the PlayerInputManager and I was wondering about your comment.

    If I were to have PlayerInputManager in the Main Menu, and join players. I'm guessing I would store the PlayerInput on join somewhere.
    So that when I changed scenes to the Main Game, I would apply the stored the PlayerInput on the player.
    The question is, how would I apply the stored PlayerInput onto the real in-game characters?
     
  4. m4rtin-t

    m4rtin-t

    Joined:
    Jan 30, 2016
    Posts:
    8