Search Unity

Linking scripts in a multiplayer environment

Discussion in 'Scripting' started by karimcambridge, Dec 1, 2015.

  1. karimcambridge

    karimcambridge

    Joined:
    May 3, 2014
    Posts:
    4
    Fixed.


    Okay, I know how to link scripts in a single player environment, pretty easy.

    But in this case, I instantiate my pause canvas per each player. I have a PlayerUIManager game object with the PlayerUIManager script attached to it.

    So now in PlayerMouseLook, I don't want the player to be able to move the mouse around while paused, so I need access to the variable. What I did before worked fine for a single player environment where I had the canvas in the hierarchy all the time.

    Code (CSharp):
    1.  
    2. public GameObject playerUIManagerObject;
    3.  
    4. private PlayerUIManager playerUIManagerScript;
    5.  
    6. private void Start()
    7. {
    8.             playerUIManagerScript = playerUIManagerObject.GetComponent<PlayerUIManager>();
    9. }
    In the GameObject, I put the prefab of the PlayerUIManager, but that doesn't seem to work.

    Any ideas? The GameObject is a child of the Player prefab where PlayerMouseLook is located.. maybe that can help?
     
    Last edited: Dec 2, 2015