Author Topic: NGUI in 3D coordinates  (Read 5359 times)

HazardousInteractive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
NGUI in 3D coordinates
« on: April 30, 2014, 09:57:40 PM »
hello,

How can I make a GUI that hovers over a character to say to show its name/health etc... And gets smaller when the player goes farther or closer, and always faces the player

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI in 3D coordinates
« Reply #1 on: May 01, 2014, 07:36:21 AM »
If you are doing it in 2D, then you need to write a script that will scale the game object containing your healthbar based on the distance from the camera to the object the health bar is following.

HazardousInteractive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: NGUI in 3D coordinates
« Reply #2 on: May 01, 2014, 09:23:23 AM »
If you are doing it in 2D, then you need to write a script that will scale the game object containing your healthbar based on the distance from the camera to the object the health bar is following.
And how can I make it be above the character?

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: NGUI in 3D coordinates
« Reply #3 on: May 01, 2014, 09:42:16 AM »
Adjust the Y coordinate relative to the player (or Z, or X, or whatever depending on your setup), either before or after you transform the position from world to camera or whatever.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI in 3D coordinates
« Reply #4 on: May 02, 2014, 08:11:56 AM »
I generally just have a child game object of the 3D object that's offset to be above the 3D object. I target this child object instead of the 3D object, resulting in the 2D UI being offset automatically.