Files
FablishRPG/Assets/Scripts/Billboard.cs

25 lines
591 B
C#
Raw Normal View History

using UnityEngine;
/// <summary>
/// Place this on your WorldSpace Canvas to make it always face the player's camera!
/// </summary>
public class Billboard : MonoBehaviour
{
private Camera _mainCamera;
private void Start()
{
_mainCamera = Camera.main;
}
private void LateUpdate()
{
if (_mainCamera != null)
{
// Makes the Canvas look exactly at the camera, then flips it 180 degrees
// so the text isn't backwards!
transform.LookAt(transform.position + _mainCamera.transform.forward);
}
}
}