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 Crashdoom · Jul 09, 2012 at 01:52 AM · c#objectlabel

Name above object C#

I'm trying to get a persistent name label above certain objects within my game. At the moment, I'm trying to use http://www.unifycommunity.com/wiki/index.php?title=ObjectLabel but it seems that the label continually moves and also appears when I turn the camera to face away from the object.

What I'm trying to get is a label that doesn't move from the position above the object/character. I'm really stumped and any help would be appreciated :)

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 Crashdoom · Jul 09, 2012 at 11:23 AM 0
Share

Would it be better/easier to use a textmesh/object above the NPC (object)? If so, how?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by aldonaletto · Jul 09, 2012 at 02:40 AM

You can check if the object isn't behind the camera using a simple dot product between the camera's forward direction and the direction camera->object - a negative dot product means the object is behind the camera.

... void Update(){ if (Vector3.Dot(camTransform.forward, target.position-camTransform.position) < 0){ // object behind camera: guiText.enabled = false; // make label invisible... return; // and abort further calculations } guiText.enabled = true; // otherwise make label visible

 if (clampToScreen){ // rest of Update unmodified
     ... 

Comment
Add comment · 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 Crashdoom · Jul 09, 2012 at 03:12 AM 0
Share

Okay, that fixed the issue of it appearing when it shouldn't, but the label is still moving about randomly when I move my camera... http://db.tt/QrAgpZCz is a screenshot of my Unity showing the offending GUI Text and its respective settings.

avatar image aldonaletto · Jul 10, 2012 at 05:17 PM 0
Share

The GUIText must not be childed to anything - drag it out of the Cylinder object and the ObjectLabel will keep it s$$anonymous$$dily attached to the target. GUIText and GUITexture must never be childed to 3D objects, because their position fields must be in the 0..1 range, and any parent movement kicks the GUI element out of screen.

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

7 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

how to put in function any variables? like object? 2 Answers

Rotate the Object 90 Degrees 1 Answer

Writing property of object to the console? 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