Is there a way to show the name of an object above it?
Use a GUIText, or a 3D Text component attached to a GameObject.
Then to position the text, you’d either (in C#):
For GUIText:
using UnityEngine;
using System.Collections;
public class MyEnemyName : MonoBehaviour {
public Transform enemy; //enemy's transform
public Vector3 positionOffset = Vector3.up; //offset relative to enemy's origin, so it doesn't, say, draw the text at the enemy's feet
public void Update() {
//keep in mind this needs special code if your enemy is behind the camera
transform.position = Camera.main.WorldToViewportPoint(enemy.position + positionOffset);
}
}
For 3D Text:
using UnityEngine;
using System.Collections;
public class MyEnemyName : MonoBehaviour {
public Transform enemy; //enemy's transform
public Vector3 positionOffset = Vector3.up; //offset relative to enemy's origin, so it doesn't, say, draw the text at the enemy's feet
public void Start() {
//keep in mind 3D Text draws on top of everything,
//unless you use the 3D text shader from here:
//http://wiki.unity3d.com/index.php?title=3DText
transform.position = enemy.position + positionOffset);
transform.parent = enemy;
}
}