• 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 /
  • Help Room /
avatar image
0
Question by Robert Ahearne · Apr 13, 2016 at 06:33 AM · javascriptguicolliderontriggerenterontriggerexit

Text disappear on OnTriggerExit()

Hi wondering if anyone can help, I have this script placed on a Game Object, when my FPScontrolled which is set to "is Trigger" collids with the gameObject the text appears "Door is locked" but when I walk out of the area the text does not disappear anyone know where im going wrong? thank you

 var ShowGUI : boolean;
 
 function OnTriggerEnter(info : Collider)
 {
     ShowGUI = true;
 }
 
 
 
 function OnGUI()
 {
     if(ShowGUI == true)
         GUI.Label(Rect(400,300,100,20), "Door is Locked");
 }
 function onTriggerExit(info : Collider)
 {
     ShowGUI = false;
 }
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 JigneshKoradiya · Apr 13, 2016 at 06:45 AM

  var ShowGUI : boolean;
  
  function OnTriggerEnter(info : Collider)
  {
      ShowGUI = true;
  }
  
  
  
  function OnGUI()
  {
      if(ShowGUI == true)
          GUI.Label(Rect(400,300,100,20), "Door is Locked");
  }
  function OnTriggerExit(info : Collider)
  {
      ShowGUI = false;
  }



copy this will work

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 Robert Ahearne · Apr 13, 2016 at 06:58 AM 0
Share

Thank you so much this worked

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

93 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 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 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 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 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 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

math.Lerp not correct? 1 Answer

I want that when my character enter into a room a video automatically play and when he leaves the room the video "turns off". 1 Answer

How do I differentiate between the triggers? 1 Answer

OnTriggerExit2D doesn't work when one of gameObject setActive false. 0 Answers

OnTriggerEnter For Parking 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges