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 andrewjm10 · Jun 30, 2013 at 07:01 PM · errornoobsupport

Enter Trigger, display Text, then delete object

I am a noob at this stuff, only been doing a little while and i found a script that will display text one the Tag="Player" enters into the box collider, now it worked great.

It displays it in the center and lets me close it, but the only issue is that every time i walked into it it would pop up and i had to click close, over and over.

So i tried to add a delete function, it did delete it but the problem is it deletes it before it even loads the text to read.

 var player : GameObject;
 private var bool : boolean;
  
 function OnTriggerEnter(other : Collider) {
 if(other.tag == "Player") {
 bool = true;
 Destroy(gameObject);
 }
 }
  
 function OnGUI(){
 if(bool == true) {
 if(GUI.Button (Rect (500, 300, 500, 80), "You can move by pressing the W,A,S,D Keys\nPress Space Bar to Jump, (E) Key is Action!\n\n[Click to close]")) {
 bool = false; 
 }
 }
  
 }

So it keeps deleting it before i can ever display it, or i move it and nothing happens anyone know what i am doing wrong thanks.

Edit: I was told a button is not a good way but i don't know anyone other way to achieve this, i wanted to make it check to see if a box was already open but did not work maybe you experts can offer an alternative?

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

Answer by Slobdell · Jun 30, 2013 at 07:08 PM

You're destroying it when it enteres the collider, try this

 var player : GameObject;
 private var bool : boolean;
  
 function OnTriggerEnter(other : Collider) {
 if(other.tag == "Player") {
 bool = true;
 }
 }
  
 function OnGUI(){
 if(bool == true) {
 if(GUI.Button (Rect (500, 300, 500, 80), "You can move by pressing the W,A,S,D Keys\nPress Space Bar to Jump, (E) Key is Action!\n\n[Click to close]")) {
 bool = false; 
 Destroy(gameObject);
 
 }
 }
  
 }
Comment
Add comment · Show 9 · 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 andrewjm10 · Jun 30, 2013 at 07:16 PM 0
Share

Ok thanks, it looks like it worked i exited the collider and walked back in and it did not appear again thanks.

Is there a way to make it check if there is already a window open? I noticed it keeps stacking up over each other.

avatar image Slobdell · Jun 30, 2013 at 07:27 PM 0
Share

There should only be one. $$anonymous$$akes me think you either have the script attached more than once to the same object, attached to multiple objects, or multiple of the same object in the scene. It will show up once for each script that is active somewhere.

avatar image andrewjm10 · Jun 30, 2013 at 07:36 PM 0
Share

Yeah i do i have it attached to different signs, is there a way to define it in the script above for multiple objects? or by Tag ID?

avatar image Slobdell · Jun 30, 2013 at 07:42 PM 0
Share

Well what's the purpose of this? I'm assu$$anonymous$$g the message above is just for the first time they start playing and then it never shows again. What messages are supposed to pop up and when/why?

avatar image andrewjm10 · Jun 30, 2013 at 07:49 PM 0
Share

I guess it would help what i am using it for sorry, So when a player is walking along he/she will trigger a Sign(Collider) that will display a message. The first one is below the Player>Controller so when it lands (on play) it will pop up with the control info. then i have them along special points to give them Tip's and Helpful info.

Does that make sense lol? Like a Tip System, i thought by making each script with my code it would work, but as you pointed out it should only display one but because i have it set up half a** it don't work > Noob

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

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

Multiple Cars not working 1 Answer

Only access door if it's not locked? 1 Answer

Script outdated i think, Unity 4 - Compiler errors galore 1 Answer

What is wrong with my RockPaperSissors script? 1 Answer

error cs0120 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