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 bigdaddychez · Sep 30, 2012 at 02:19 PM · guitexthitbox

print on screen

okay so i have an hit box (isTgigger) i want to make it so that when my player hits the box a GUI text appears on screen, displaying some information, the text is removed upon the player ceasing contact with the hit box. i have a code wich i don't know if will work or not.

function OnTriggerEnter (other : Collider) { #inser code for printing info on screen here# }

can some1 help me?

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
1
Best Answer

Answer by AlucardJay · Sep 30, 2012 at 02:57 PM

Keep track of if something is within the trigger with a boolean. Then if that boolean is true, display the GUI :

 var withinTrigger : boolean = false;
 
 function OnTriggerEnter (other : Collider) 
 {
     withinTrigger = true;
 }
 
 function OnTriggerExit (other : Collider) 
 {
     withinTrigger = false;
 }
 
 function OnGUI()
 {
     if ( withinTrigger )
     {
         GUI.Box( Rect( (Screen.width * 0.5) - 100, 10, 200, 25 ), "Within the Trigger !" );
     }
 
 }
Comment
Add comment · Show 7 · 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 sacredgeometry · Sep 30, 2012 at 03:31 PM 0
Share

Ahh yeah I misread, I though he was using the guiText component ... its a much better idea to do it this way, although not sure why you used GUI.BOX over GUI.Label

avatar image AlucardJay · Sep 30, 2012 at 03:38 PM 0
Share

Force of habit, I only use Unity's GUI for debugging / displaying stats while testing, and always use Box for that! I think it's for the contrast and the centering of the text. I have written and use my own GUI for my projects.

avatar image bigdaddychez · Sep 30, 2012 at 03:43 PM 0
Share

tnx dude. i'm using this as a tutorial in my game. (when approaching the first gap it's gonna display: "press Space to jump" and u'r script was just what i needed

avatar image AlucardJay · Sep 30, 2012 at 03:45 PM 0
Share

the code formatting has not included the first line, so if you just copied then you are missing the first line. I have just fixed the code block (the first line was always there, perhaps read the code?).

Are you familiar with trigger? http://www.unity3dstudent.com/2010/07/beginner-b13-trigger-collision-detection/

avatar image AlucardJay · Sep 30, 2012 at 03:48 PM 0
Share

If you are just starting out, then the whole series might be helpful to watch :

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/

this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp

the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials

A list of resources : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html

Show more comments

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

12 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

Related Questions

GUI text font change 3 Answers

Limit on GUI Components? 0 Answers

Using "fonts" that are actually images for a multi-outline effect. 2 Answers

Dialouge text. 1 Answer

Unity GUI text displaying as noise 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