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

UNET Find local player controller from NetworkLobbyPlayer

Discussion in 'UNet' started by Samuel411, Aug 30, 2015.

  1. Samuel411

    Samuel411

    Joined:
    Dec 20, 2012
    Posts:
    646
    Hello, I'm trying to change variables on the PlayerController from my LobbyPlayer, right now I'm using this,
    Code (CSharp):
    1.  
    2. // Set username
    3. if(!controllerTeamManager && Application.loadedLevel != 0 && isLocalPlayer)
    4. {
    5.        controllerTeamManager = NetworkLobbyManager.singleton.client.connection.playerControllers[0].gameObject.GetComponent<TeamManagement>();
    6.        controllerTeamManager.username = username;
    7. }
    8.  
    As you can see I'm trying to pass a string to the TeamManager for the player, however the issue I'm having is that this is only working on the server, the PlayerController is found only if you are the server. If a client is not the server then it cannot find the playerController (it returns it as null). What I need is to get the local player's PlayerController. I've been searching all over and can't find anything. Anyone have any idea on how to do this? Thanks.
     
  2. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685