- Home /
Answer by Berenger · Feb 21, 2012 at 10:54 PM
Create a GUIText and attach that script on it. Make it child of the character, set the target in the inspector (or change the script to get the parent) and tweak the offset.
using UnityEngine;
using System.Collections;
public class DisplayName : MonoBehaviour
{
public Transform target;
public Vector3 offset;
// Update is called once per frame
void Update (){
transform.position = Camera.main.WorldToViewportPoint( target.position ) + offset;
}
}
Answer by zakkar · Feb 22, 2012 at 12:05 AM
Thanks for your answer but the textGUi follow me when i turn my camera around, i have made the text children of a pnj player and the target the pnj but when i turn with my player the caemra after some seconde i see the text appearing on the top of my screen
thank you
Your answer
Follow this Question
Related Questions
GUI Over AI characters 1 Answer
Displaying Z Rotation through script 1 Answer
Detect if any GUI is being displayed on-screen? 1 Answer
Display GUI when enter an area? 2 Answers