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 MithosAnnar · Feb 27, 2012 at 09:01 PM · guitexturetransformpositionlock

lock GUITexture on the screen at specific co - ordinates

Hello..

I have redone my game entirely without the use of OnGUI, (which was causing a lot of problems for me).

But now that I am not using OnGUI I have had to put the functionality into my GUI manually.

The issue I have is this...

my GUI is attached to my enemy, when my enemy follows the player the GUI moves with it (across and off the screen).

I have tried setting the positions in - code, but I feel this is very inefficient (especially in the Update function).

I would just like to know how this can be corrected properly. Maybe I can lock it somehow?

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

3 Replies

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

Answer by MithosAnnar · Feb 28, 2012 at 12:02 PM

Ok, I finally fixed the problem.

The solution was to make an empty GameObject and make the GUI elements a child of it and then instantiate it with the enemy.

Thanks for the help!

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
1

Answer by Berenger · Feb 27, 2012 at 11:20 PM

If you want the GUITexture to follow the character nicely, use WorldToViewportPoint instead of parenting. The position is in viewport space (0,0 => 1,1), when the parenting modify it in world space.

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 MithosAnnar · Feb 28, 2012 at 09:28 AM 0
Share

its not a healthbar above the enemy. its everything including the portrait and name that comes up when an enemy is targeted like in wow.

avatar image
0

Answer by Meltdown · Feb 28, 2012 at 09:45 AM

Attach your GUI to your camera. When you click on the enemy, pass in your enemy information to your camera GUI script.

Alternatively what I do for my GUI is create a second orthographic camera with a higher depth than my main camera, and add a few 2 triangle planes in the right position and put textures/text/bars on them.

You will also need to do some tweaking based on the aspect ratio of the user's screen so make sure to test and adjust the GUI accordingly.

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

6 People are following this question.

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

Related Questions

Game Texture - Always Face Camera 1 Answer

transform.position as variable to lock object 0 Answers

Finding the limits of transform coordinates 1 Answer

How to use transform.position? 2 Answers

change bar position 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