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 zephyrmc · Oct 30, 2013 at 04:48 PM · cameralookatbillboard

Why does LookAt look away?

Hey folks,

I'm trying to make a billboard that always faces the camera, so I made a Quad primitive and attached the following script:

 function FixedUpdate() {
     transform.LookAt(Camera.main.transform);
 }

For some reason, this makes the quad point away from the camera, rather than towards it.

This is something I can easily fix by flipping the quad around its local Y axis afterwards, but it seems like such a brain fart on the part of Unity that I'm wondering if I missed something. If there's a "definitive" way to make a camera-facing billboard in Unity, what does it look like?

Note that I already saw this and this and a bunch of similar stuff, but nothing that relies on Transform.LookAt seems to work by itself. What's going on here?

Comment
Add comment · Show 1
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 sdgd · Oct 30, 2013 at 04:49 PM 0
Share

what does look at look from?

camera towards camera?

also the lookat that blue arrow forgot witch axis has to be toards the target

2 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by robertbu · Oct 30, 2013 at 04:53 PM

Start with a new scene and create a Quad at the origin. If you think about it, you are looking at the back side of the Quad. The forward side is facing away from the camera. When you do a LookAt() you are pointing the forward (i.e. the backside of the plane) at the position indicated. Try this instead:

 transform.rotation = Quaternion.LookRotation(transform.position - Camera.main.transform.position);
Comment
Add comment · Show 3 · 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 zephyrmc · Oct 30, 2013 at 04:58 PM 0
Share

Camera.main.transform.position - transform.position doesn't work, but transform.position - Camera.main.transform.position does. I'm beginning to suspect that the built-in quad mesh is just oriented the wrong way.

avatar image robertbu · Oct 30, 2013 at 05:09 PM 0
Share

Yea. I got the parameters backwards. 'Wrong way' is relative. As mentioned in my answer, the visible side is the back.

avatar image zephyrmc · Oct 30, 2013 at 05:13 PM 0
Share

Fair enough. Thanks!

avatar image
0

Answer by RomamoramenTo · Apr 08, 2018 at 09:03 AM

You can also do the same thing by: transform.LookAt(transform.position * 2 - Camera.main.transform.position);

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

17 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

Related Questions

problem with camera and look at in unity network 0 Answers

Make the terrain ignore Raycast if in between Camera and Player? 1 Answer

Player rotates with camera(face same direction as the camera) 1 Answer

How to make camera position relative to a specific target. 1 Answer

An alternative to RotateAround for collisions 0 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