Add billboard behaviour component
This commit is contained in:
20
Assets/Scripts/BillboardBehaviour.cs
Normal file
20
Assets/Scripts/BillboardBehaviour.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BillboardBehaviour : MonoBehaviour
|
||||
{
|
||||
private Vector3 initialRotation;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
initialRotation = transform.rotation.eulerAngles;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.LookAt(Camera.main.transform.position);
|
||||
transform.rotation = Quaternion.Euler(new Vector3(initialRotation.x, transform.rotation.eulerAngles.y, initialRotation.z));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user