Advertisement
Guest User

Billboard Unity3D

a guest
Jun 23rd, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement