hello , i have a problem. A want to output text above the GameObject. How can i realize it?
You can use à 3D Text and attach some script to dynamically change the text or use à guiText And use that simple script in order to make the guiText follow the object
using UnityEngine;
using System.Collections;
public class GUITextFollow : MonoBehaviour
{
public GameObject Reference; //The object you want to follow
public Vector3 Offset;
// Update is called once per frame
void Update()
{
transform.position = Camera.main.WorldToViewportPoint(Reference.transform.position) + Offset;
}
}
You can use that little script with à guiTexture too! a healthbar?
yep:)
thank you, it works
you can also use Camera.WorldToScreenPoint to calculate the position on the screen and display a 2d text there. but you have to check if point is in front of camera additionally.
i guess this could be usefull, too.