• 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
Question by dzioniux · Feb 22, 2012 at 03:26 PM · collisionguiguitexturefunctions

Question about pop up boxes during the game

Hey,

I would like to ask for help, maybe somebody can explain to me how I can create GUI pop up box (text, images and links), which will appear when player hits the wall and disappear when he will move away. For example: I have small town with a few buildings and during the navigation when player will come closer to precise building the info box will appear (which will present info about that building: photos, text and etc.) and when he moves away from the building then info box will disappears. I am kind of new with unity, so I would be glad if somebody can explain me the code which I should use. Thank you ;-)

Dzioniux

Comment
fireomega
MithosAnnar

People who like this

0 Show 0
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

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by melatonin · Feb 23, 2012 at 11:18 PM

The code he wrote has an error. The if statements should read:

if (theCollider.gameObject.tag == "Player")

He never defined other so Unity has no idea what to do with it. Try this simple fix and you should be good.

Comment
fireomega
MithosAnnar

People who like this

0 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 dzioniux · Feb 24, 2012 at 05:16 AM 0
Share

yes, I fixed it. Thank you ;-)

avatar image fireomega · Mar 19, 2012 at 07:31 PM 0
Share

I write an entire script and he gets the tick?

avatar image

Answer by fireomega · Feb 22, 2012 at 08:38 PM

one way is you could have two scripts such as the one for the gui which you attach to an empty gameObject. I'm assuming you know how to make a gui box already. Name the object e.g. Info

Then make a empty gameObject at the building and attach a collider and make it a trigger. Then write something like:

 var info : GameObject;
 
 function Start () {
 info.active = false;
 }
 
 function OnTriggerEnter(theCollider : Collider){
 if(other.gameObject.tag == "Player"){
 info.active = true;
 }}
 
 function OnTriggerExit(theCollider : Collider){
 if(other.gameObject.tag == "Player"){
 info.active = false
 }}

haven't tested it yet, if there are any problems please ask.

Comment
MithosAnnar

People who like this

1 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 dzioniux · Feb 23, 2012 at 04:14 PM 0
Share

Hi,

First of all, thank you for your answer ;-). I done all steps as you wrote, but I got an error: Assets/collision_info.js(9,4): BCE0005: Unknown identifier: 'other'. Should I somehow define 'other' and my question about "gameObject.tag == "Player" " this means that it will use fps pref. which tag is Player, yes?

Best

Dzioniux

avatar image melatonin · Feb 23, 2012 at 04:54 PM 0
Share

There is a simple error in the code. The if statement should read like this:

if ( theCollider.gameObject.tag == Player")

He is using other and since that hasn't been defined Unity doesn't know what to do with it.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

script to create gui when detection collision between cube and first controler person ?? 1 Answer

UFPS:ultimate fps cameraGUI texture wont show in game 0 Answers

Draw GUI texture from it's center point. 2 Answers

What am I doing wrong? C# 1 Answer

GUITexture scaling with aspect ratio? 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