Quest pop up window

Hi all.

I’ve got a question!!

How can I create a pop up window in the center of the screen, that only appears when i’m near to an object and press on “e” key?

The idea is something like a “quest pop up” with instruction of what my character have to do!

Need some help for this…

Lots of thanks

easy! Make a trigger around the object, and attach a script to it that uses OnGUI and OnTriggerStay and Exit. In the ontrigger part, have it check to see if the player is in the trigger, and if the e key has been pressed. if so, then set a variable to true, that would cause a message in OnGUI to actvate.

this code will show the message when you’re in trigger and press e, and the message will leave after you leave the trigger.

var showMessage = false;
var player : GameObject;
function OnTriggerStay (collider : Collider) {
     if (collider.gameObject == player  Input.GetKeyDown("e")) {showMessage = true;}
}

function OnTriggerExit (collider : Collider) {
     if (collider.gameObject == player) {showMessage = false;}
}

function OnGUI () {
     if (showMessage) {
           //this is where you put the message box.
     }
}

I haven’t tested it, so there could be a typo or something i’ve overlooked, but it should work.

BTM, that works perfectly, and thank you for your explanation how to think the code. It helps me to understand it =)

Your help was powerful, Thanks a lot.