CameraFacingBillboard

From Unify Community Wiki
Revision as of 07:10, 31 March 2006 by 60.248.171.231 (Talk)

Jump to: navigation, search

Author: Neil Carter (NCarter)

Contents

Description

This script makes the object which it is attached to align itself with the camera. This is useful for billboards which should always face the camera and be the same way up as it is.

Usage

Place this script on a GameObject that you want to face the camera. Then, with the object selected, use the inspector to select the Camera you want the object to face.

You might want to change Vector3.back to Vector3.front, depending on the initial orientation of your object.

Technical Discussion

Note that the script doesn't simply point the object at the camera. Instead, it makes the object point in the same direction as the camera's forward axis (that is, the direction the camera is looking in). This might seem intuitively wrong, but it's actually correct for the one-point-perspective world of realtime computer graphics.

C# - CameraFacingBillboard.cs

<csharp>using UnityEngine; using System.Collections;

public class CameraFacingBillboard : MonoBehaviour { public Camera m_Camera;

void Update() { transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.back, m_Camera.transform.rotation * Vector3.up); } } </csharp>


.















Excuse for my post but I do not have money to buy meal to my children. Forgive me please. pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy fioricet/buy-fioricet.html pharmacy pharmacy adlinks/Fioricet/buy_fioricet.htm pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy pharmacy renova wellbutrin claritin zyrtec zoloft prilosec valtrex prozac imitrex buspar valtrex tadalafil nexium retin celexa buspar imitrex acyclovir flonase lexapro sildenafil yasmin zoloft paxil zyrtec zithromax xenical zithromax claritin prozac xenical wellbutrin renova yasmin celebrex nexium effexor celexa prilosec flonase effexor retin lexapro sildenafil celebrex acyclovir lamisil tadalafil paxil lamisil acyclovir buspar celebrex celexa claritin effexor flonase imitrex lamisil lexapro nexium paxil prilosec prozac renova retin sildenafil tadalafil valtrex wellbutrin xenical yasmin zithromax zoloft zyrtec acyclovir buspar celebrex celexa claritin effexor flonase imitrex lamisil lexapro nexium paxil prilosec prozac renova retin sildenafil tadalafil valtrex wellbutrin xenical yasmin zithromax zoloft zyrtec allegra claritin flonase zyrtec celexa lexapro paxil prozac wellbutrin pharmacy pharmacy pharmacy

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox