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 yosh · Jun 02, 2010 at 04:00 PM · cameratransform

Transform.LookAt - wrong vector

Hi,

i ve created a gameobject with a simple plane. The material is a transparent/vertexlit and i gave it simple 2d-grafic as the base-texture. Now ive added the following script/code.

private void Update(){
transform.LookAt(Camera.main.transform);
}

If i run the gamemode, the texture always has the wrong rotations, so ive never see it. All these gameobjects should everytime directly face up to my orbit-camera. Unfortunately ive too few knowledge about vector-math, so therefore it would be great to get some hints on that..

thanks a lot,

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

4 Replies

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

Answer by Random Indie · Jun 03, 2010 at 12:21 AM

Might be that the plane doesn't have the forward direction you're thinking it does. If I remember correctly the lookat function uses the forward vector which I think is the positive z axis for the game object (might be x but IIRC I think x is 'right').

So depending on how you set up the plane it might be looking in the right place, but on it's side so you only see the edge and therefor might not actually 'see' it.

If that's the case you can either fix the plane's rotation in max/blender/what have you, or you can stick it it in an empty gameobject and orient it properly as a child then stick the rotation code on the parent gameobject.

Hope that helps, if you need clarification on anything let me know.

Cheers

Comment
Add comment · Show 1 · 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 yosh · Jun 07, 2010 at 08:39 AM 0
Share

Thanks to all for there quick help. It helps to create a extra gameobject and rotate the plane-go inside of it.Thanks

avatar image
1

Answer by Mike 3 · Jun 02, 2010 at 04:06 PM

Try using transform.rotation = Camera.main.transform.rotation

Sprites and Planes are very often made so that they face the camera when oriented the same way

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
avatar image
0

Answer by Tetrad · Jun 02, 2010 at 04:19 PM

Try comparing what you're doing to this script:

http://www.unifycommunity.com/wiki/index.php?title=CameraFacingBillboard

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
avatar image
0

Answer by Peter G · Jun 02, 2010 at 05:59 PM

Not sure if you created your own plane or not, but if you did, you might have assigned the vertices in the wrong order. Try reversing the direction you assign the points in i.e. clockwise instead of counter-clockwise or vice-versa.

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

No one has followed this question yet.

Related Questions

C# locking Main Camera's Rotations 1 Answer

how to move the camera using the mouse scroll in all direction? 0 Answers

Camera, Offsetting the Transform.LookAt 2 Answers

Pan Orthographic Camera 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 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