Billboard experiments

While researching how to implement a dialogue system (vomit emoji) in Unity3D I randomly ended up finding this awesome blog post about Billboard orientation for 2D spites using 3d cameras in perspective mode. This shows some of the quick experiments I whipped up after implementing his ideas. Pretty elegant solution for an annoying problem.


// BillboardSprite.cs
using UnityEngine;
using System.Collections;

public class BillboardSprite: MonoBehaviour {

	public Transform MyCameraTransform;
	private Transform MyTransform;
	public bool alignNotLook = true;

	// Use this for initialization
	void Start () {
		MyTransform = this.transform;
		MyCameraTransform = Camera.main.transform;
	// Update is called once per frame
	void LateUpdate () {
		if (alignNotLook)
			MyTransform.forward = MyCameraTransform.forward;
			MyTransform.LookAt (MyCameraTransform, Vector3.up);