Author Topic: Simplest way to get UILabel follow gameobject  (Read 6460 times)

DJVDJV

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Simplest way to get UILabel follow gameobject
« on: January 19, 2016, 04:54:06 PM »
What is simplest way to get UILabel follow gameobject. (I want show name top of player). I tried UIFollowTArget script but cannot get it work. What is easiest way / is there any tutorial?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Simplest way to get UILabel follow gameobject
« Reply #1 on: January 20, 2016, 08:29:50 AM »
UIFollowTarget is the easiest solution. Not sure why you can't get it to work. It's literally as simple as attaching that script to the label and specifying your game object as the target.

Just make sure that your layers are set properly. Your UI camera should only be drawing your UI layer, and your game camera should not be drawing the UI layer.

DJVDJV

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: Simplest way to get UILabel follow gameobject
« Reply #2 on: January 20, 2016, 03:37:15 PM »
Hellos,

Got it work :). Now I wonder what is best way to put some offset. It appears now top of player. I want it over head.

I wonder why there is no "offset" in script?

It would be nice to use it somewhat like this in row 96:
pos = gameCamera.WorldToViewportPoint(target.position + offset);
« Last Edit: January 20, 2016, 04:24:51 PM by DJVDJV »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Simplest way to get UILabel follow gameobject
« Reply #3 on: January 25, 2016, 10:03:10 PM »
Simple.

GameObject (UIFollowTarget)
- Child object, offset by X (can put your UILabel here, or make it a child if you want more)