• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Nick W · Jun 26, 2010 at 02:26 PM · iphonegraphicseffectgrassbillboard

How to create billboarding planes

Hi, I havent been able to find any tutorials on how to billboard a plane with unity iphone. For example, i want to have a plane with a grass texture on it, and as I move around it, the plane rotates so that it is facing me. I know that this is used in the grass in the Island demo, so I know it is possible. Thank you in advance.

PS: If I applied a "look at" script to each piece of grass, would that be the most efficient way, or is there an easier and faster way built into unity?

Comment
Tetrad
Bryan 1
David 3
ahungrybear
goatman1

People who like this

5 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Mike 3 · Jun 26, 2010 at 02:45 PM

For planes, you can just use this to billboard them:

function Update()
{
    transform.rotation = Camera.main.transform.rotation;
}

Which you can optimize a little more if you store a reference to the camera's transform in Start

Comment
Ashkan_gc
tabworldmedia
ahungrybear
bradclovell
Jason2014
FlightOfOne

People who like this

6 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image David 3 · Dec 15, 2010 at 03:49 PM 0
Share

what if you need to rotate the original object? then rotate it to look at the user - how do i transform it?

avatar image jamesflowerdew · Mar 01, 2016 at 04:57 PM 0
Share

I like this answer, but...
Use a "Quad". This is like a plane, but not facing a silly direction by default, and not with a silly polycount either. A plane will face the sky with this code, a quad will billboard. "Quad" is like "Real-plane" imho. If you plan millions of them consider storing camera.main.transform. as a static variable (better still?) for grass store the camera's rotation too, if like me, you want thousands. as a quaternion. You can then transform.Rotate(Vector3 whatever) to get your new rotation if it's specifically different, but I'd forget this with thousands of instances.

avatar image

Answer by Ashkan_gc · Jul 10, 2010 at 04:03 PM

just add this to the bilboard in a script

function LateUpdate ()
{
myTransform.LookAt(target);
}
function Awake ()
{
var myTransform = transform; //cache the transform
var target = Camera.main.transform; //cace the transform of the camera
}

always use caching in iphone if you are not memory bound.

Comment
Tetrad
vancura

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by tektor · Aug 03, 2012 at 06:25 PM

Unless the camera moves or rotates, the target doesn't need to rotate. And since you normally know when the camera has moved or rotated (since something in your code made that happen), you can update the billboard's rotation then. No need to do it every frame!

Comment
rudidev08
FlightOfOne

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by vikingfabian-com · Dec 06, 2013 at 07:42 PM

I tried the lookat(), but that looked really bad, this is what worked for me (however, best would probably be to make a shader that rotates them)

 //use the scripts on quads
 //example:
 //GameObject go = GameObject.CreatePrimitive(PrimitiveType.Quad);
 //go.gameObject.AddComponent(typeof(Billboard3D));
 
 /// <summary>
 /// Billboard that only rotates in one angle and looks flat from above
 /// </summary>
 public class Billboard2D : MonoBehaviour
 {
     Camera cam;
     void Start()
     {
         cam = Camera.main;
     }
     void Update()
     {
         //made for a game where Y is up
         Vector3 rot = cam.transform.rotation.eulerAngles;
         rot.x = 0;
         rot.z = 0;
         transform.rotation = Quaternion.Euler(rot);
     }
 }
 
 /// <summary>
 /// Will make a quad always face the camera
 /// </summary>
 public class Billboard3D : MonoBehaviour
 {
     Camera cam;
     void Start()
     {
         cam = Camera.main;
     }
     void Update()
     {
         transform.rotation = cam.transform.rotation;
     }
 }
Comment
Flint Silver
bradclovell

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by LawyerOfGod · Oct 19, 2014 at 07:55 PM

Make sure Z axys is forward...

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

The Best Way To Make Stylised Grass in Unity? 0 Answers

Is it possible to make grass, like in the terrain as a gameobject? 0 Answers

Application.LoadLevel question 2 Answers

FilterMode.Point doesn't work with WebcamTexture on iOS 0 Answers

iOS WebCamTexture Displaying Wrong Resolution 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges