Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by HuskyPanda213 · Jan 14, 2014 at 04:56 PM · transformlookatbillboard

How to lock a billboard?

How do I make my billboard that the x is not moving so it does not look wierd, right now it rotates too which I do not like.

CODE:

 private void Object_Billboard(){
         transform.LookAt (transform.position + playerTarget.transform.rotation * Vector3.down, playerTarget.transform.rotation * Vector3.back);
     }
Comment
Add comment · Show 3
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 robertbu · Jan 14, 2014 at 05:23 PM 0
Share

The usual solution is to move the point on the 'y' axis so that it is at the same level as the rotating object. It can be done in a couple of different ways. I'd write you a bit of code for it, but I'm confused about your current line of code. It appears that you are looking same direction as the bottom of your 'playerTarget' and preferring to rotate around the 'z' axis of 'playerTarget'? What is the natural orientation of the object this script is attached to?

avatar image HuskyPanda213 · Jan 14, 2014 at 07:08 PM 0
Share

The object faces upward with the forward axis. Because of its rotation from the start, I do not know hot to do this otherwise.

avatar image MFen · Jan 14, 2014 at 07:45 PM 0
Share

That is one of the exact functions I created that is being sold on asset store.

C# Scripting Extension

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Jan 14, 2014 at 07:49 PM

I still cannot visualize your specific situation. But let me show how it would be done for some common scenarios, and you can translate into your object configuration.

Imagine a camera and a Quad. In a Quad, the visible surface is the back. If you were to billboard but only rotate on the 'y' axis regardless of the camera angle (and the Quad lived on the XZ plane), you would do it this way:

 var v = Camera.main.transform.forward;
 v.y = 0;
 transform.rotation = Quaternion.LookRotation(v, Vector3.up);

If this was a normal game object in which you wanted to face the camera, the change would be:

 transform.rotation = Quaternion.LookRotation(-v, Vector3.up);

Your situation is different, so how you apply this logic will be a bit different. The two important points are are 1) the projection of the point onto a plane by zeroing out one component of the look vector, and 2) the second parameter to the LookRotation being the axis you want to rotate around.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using LookAt method to get object X rotation to face another object 1 Answer

transform.LookAt issue 1 Answer

How to prevent Z axis rotation ? 1 Answer

LookAt transform plus a y value 1 Answer

Object moves toward another object when close 2 Answers


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