Author Topic: Create HUD for a new player  (Read 3659 times)

meeydoo

  • Guest
Create HUD for a new player
« on: April 14, 2012, 10:23:31 AM »
hey,

lets say i want to spawn the player at runtime. The player prefab has some variables like Gameobject healthbar etc. I need to assign these values. How do i do that ?
Because i can only assign variables in the Hierarchy window, but i need them assign them in the project window (prefab).

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Create HUD for a new player
« Reply #1 on: April 14, 2012, 10:25:54 AM »
You just assign it in the code that Instantiates the prefab.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Create HUD for a new player
« Reply #2 on: April 14, 2012, 01:59:28 PM »
I recommend having a script on the UI elements that watches something in the world, whether by having your instantiation script set up the references, or by having the UI script find what it's supposed to watch automatically (if you only have one player, this is easier).