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
1
Question by oliver-jones · Sep 13, 2013 at 02:41 PM · cameraguitexturetransform

Game Texture - Always Face Camera

Hello,

Before you say this question has been asked multiple times, bear with me (it's different)...

I want to get a texture within my scene to face my camera at a certain way. When I use:

 transform.LookAt(Camera.main.transform);

It works fine, but I want my texture to appear more like a GUI, but with depth (so you can't see it behind a game object).

Let me show:

alt text

Both the alert textures have the LookAt camera attached to them, and as you can see - its working, but not how I want.

alt text

This is how I want them to look. No matter where I am facing, the textures will always point 'directly' down the scene (instead of directly at the cloud point of the camera.

Any ideas how I can achieve this?

screen shot 2013-09-13 at 15.38.34.png (102.6 kB)
screen shot 2013-09-13 at 15.39.43.png (100.8 kB)
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

1 Reply

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

Answer by fafase · Sep 13, 2013 at 02:50 PM

Could it be that you do not want them to face your position but instead to align with the opposite of your forward vector?

 transform.rotation = Quaternion.LookRotation(-Camera.main.transform.forward);
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 oliver-jones · Sep 13, 2013 at 03:00 PM 0
Share

Exactly what I'm looking for. Could you do me one more? Could you make it so I can tweak the x, y, z rotation variables (for example, my texture it now facing in the opposite direction - so I need to rotate it +180, on top on this code.

Thanks

avatar image fafase · Sep 13, 2013 at 03:11 PM 1
Share

I don't quite get it. If your texture is facing the opposite way, just remove the - from Camera.main.transform.forward. What do you mean by tweaking values?

avatar image Techn0man fafase · Apr 06, 2018 at 07:23 PM 0
Share

I think he means to add on to the values like this

 float x = Camera.transform.forward.x + #number here#;

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

16 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

Related Questions

My GUI elements are not rendering on top of all cameras. Any ideas why? 1 Answer

Camera.main.WorldToViewportPoint & GuiTexture 2 Answers

Finding the limits of transform coordinates 1 Answer

My GUI Texture Disappears? 0 Answers

Apply Render Texture To GUI + Transparency? 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