[Combat Text] Fade Text & Face Towards Camera

My text goes up just fine, but how do I make my text face towards the camera? Also, how do I alter my texts’ alpha channel so I can create a “fade away” effect?

Note: I use a text mesh on a “dummy” game object.

using UnityEngine;
using System.Collections;

public class CombatText : MonoBehaviour
{
    void Update()
    {
        transform.Translate(Vector3.up * 0.1f, Space.World);
    }
}
transform.rotation = Quaternion.LookRotation( transform.position - Camera.main.transform.position );
Renderer myTextRenderer = GetComponent<Renderer>();
Color newAlphaColor = myTextRenderer.material.color;
newAlphaColor.a = someAlphaValue;
myTextRenderer.material.color = newAlphaColor;

Note that this code is dependant on what your text shader is and if it respects the color property of a material. You can also use Material.SetColor() to set any other color property within a material.

1 Like

Thanks for the feedback. It worked great!