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