How do I add a text to Game Object and follow it in the scene?

Hi

I would like to make a Text that follow a game object in the scene.
For example, add a Character name on top of character and follow the position of the character.

I have tried GUIText and set its parent transform to a GameObject. However They are not moving in the same scale.
I also tried attach GUI Text as component to the GameObject. Same thing happen as above, they are not moving at right scale. (GUIText always moves faster than the GameObject)

Could anyone give me a hand?
The text I would like to assign are dynamic, i.e. Could not be preset before runtime.

Thanks.

3 Answers

3

Have a look at this example.

Thank you, this example is very clear to show desired result. I modify it and allow the GUI.window follow the GameObject. Thank Joshua and Meater6 help.

Link is broken

Try this using ScreenToViewPort, that should do it. Make sure to convert from pixels to relative screen size, though.

Thank you. I used WorldToScreenPoint and follow Joshua example to allow my GUI.window (any everything inside) follow the GameObject. Thank you very much.

Please can anyone help me… i have the same problem but i cant see the example…
thanks :))