working on quest and interaction system
This commit is contained in:
24
Assets/Scripts/Billboard.cs
Normal file
24
Assets/Scripts/Billboard.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user