x


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

more ▼

asked Feb 22 '12 at 03:26 PM

dzioniux gravatar image

dzioniux
11 2 2 2

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first

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.

more ▼

answered Feb 23 '12 at 11:18 PM

melatonin gravatar image

melatonin
11

yes, I fixed it. Thank you ;-)

Feb 24 '12 at 05:16 AM dzioniux

I write an entire script and he gets the tick?

Mar 19 '12 at 07:31 PM fireomega
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Feb 22 '12 at 08:38 PM

fireomega gravatar image

fireomega
356 5 7 9

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

Feb 23 '12 at 04:14 PM dzioniux

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.

Feb 23 '12 at 04:54 PM melatonin
(comments are locked)
10|3000 characters needed characters left
Be the first one to answer this question
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5087
x3693
x2499
x477
x82

asked: Feb 22 '12 at 03:26 PM

Seen: 866 times

Last Updated: Mar 19 '12 at 07:31 PM