How can You Attach GUI text above a certain
object?
Like, above a player to show ranking and name.
object?
Like, above a player to show ranking and name.
get the coordinates of the player in screen position http://unity3d.com/support/documentation/ScriptReference/Camera.WorldToScreenPoint.html
this returns you a x/y position on the screen, then place your text with an x and/or y offset to those coordinates.
I’m using a UI Text component but the solution can be used to Gui .
Code from Unity 2017.3.1f1
_bonusHit = Instantiate(_bonusHit, transform.position, Quaternion.identity);
_bonusHit.transform.SetParent(GameObject.Find("Canvas").transform, false);
_bonusHit.rectTransform.position = Camera.main.WorldToScreenPoint(transform.position);