Search Unity

Link HUD GUI to instaniated player?

Discussion in 'UGUI & TextMesh Pro' started by AwesomeX, Nov 13, 2014.

  1. AwesomeX

    AwesomeX

    Joined:
    Sep 10, 2013
    Posts:
    115
    I'm trying to figure out the best way to link my HUD to instantiated players.
    This is for a multiplayer game, and right now. I have my built HUD in the scene, and when a player joins and is instantiated, I want the HUD to know its that player's HUD.

    But I can't for the life of me figure out how set everything up. I'd honestly prefer having the GUI on the player itself, but I know that's not how it works.

    Could someone please leave me some info on this?

    Thanks.
     
  2. mdttheory

    mdttheory

    Joined:
    Nov 6, 2014
    Posts:
    11
    This would be great to know. I am having the same issue! Any ideas?
     
  3. AwesomeX

    AwesomeX

    Joined:
    Sep 10, 2013
    Posts:
    115
    The problem with the GUI system currently, is it cannot be placed ON a player as a child object. Which poses a problem to me. It's very difficult for me to link the GUI elements to the player instantiated. And there needs to be a way to make canvases children of gameObjects.
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    HUD script needs a reference to the player or the player script needs a reference to the HUD. From there you can access what ever you need. There are many ways that could achieve this.

    The script that is instantiating the player could setup the references so that the HUD or the player has access once the player has been created. Of course the instantiating script will need a reference to the HUD, which if the objects are persistent; is easily set via the editor.

    You can also setup the player to search for the HUD object in the scene using GameObject.Find("Name of object here");
    then you can get access to everything that game object has.