SHARE
TWEET

Billboard Unity3D

a guest Jun 23rd, 2013 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BillboardYAxis : MonoBehaviour {
  5.  
  6.         private Camera camToLookAt;
  7.  
  8.         //============================================
  9.  
  10.         void Awake()
  11.         {
  12.                 if (Camera.main != null)
  13.                         camToLookAt = Camera.main;
  14.         }
  15.  
  16.         //============================================
  17.  
  18.         void Update()
  19.         {
  20.                 if (Camera.main != null)
  21.                 {
  22.                         Vector3 v = camToLookAt.transform.position - transform.position;
  23.                         v.x = 0.0f;
  24.                         v.z = 0.0f;
  25.                         transform.LookAt(camToLookAt.transform.position - v);
  26.                 }
  27.         }
  28.  
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top