RiftMayhem/Assets/Scripts/UI/BillboardY.cs

22 lines
548 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BillboardY : MonoBehaviour
{
Vector3 lookat;
Quaternion lookRotation;
// Update is called once per frame
void Update()
{
lookat = Camera.main.transform.position - transform.position;
// Make the object face the camera only in the Y-axis
lookRotation = Quaternion.LookRotation(new Vector3(lookat.x, 0, lookat.z));
// Apply the rotation to the object
transform.rotation = lookRotation;
}
}