Skip to content

Instantly share code, notes, and snippets.

@walterpalladino
Created April 15, 2021 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterpalladino/0f077d186507d40cadccc8a89c55ff8d to your computer and use it in GitHub Desktop.
Save walterpalladino/0f077d186507d40cadccc8a89c55ff8d to your computer and use it in GitHub Desktop.
Unity 3D Billboard scripts
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//[ExecuteInEditMode]
public class CameraFacingBillboard : MonoBehaviour {
[SerializeField]
private Camera referenceCamera;
// Use this for initialization
void Start () {
if (!referenceCamera) {
referenceCamera = Camera.main;
}
}
// Update is called once per frame
void Update () {
}
//Orient the camera after all movement is completed this frame to avoid jittering
void LateUpdate()
{
transform.LookAt(transform.position + referenceCamera.transform.rotation * Vector3.forward, referenceCamera.transform.rotation * Vector3.up);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment