- Home /
GUI Pop-Up On Cube Collision
How would I make a GUI pop-up when my player collides with a cube? I want the GUI to be like the dialogue in an RPG game and allow you to click to continue reading the dialogue, and I want the player to be frozen until the dialogue is finished and the GUI goes away.
Answer by Liamness · Jul 09, 2013 at 11:54 PM
You could make a boolean (variable which is either true/false) called isColliding or something. Then in your player control script, you could have something like
if( !isColliding ) {
// move player according to input
}
then do something like this for the dialog
void OnGUI() {
if( isColliding ) {
if (GUI.Button(new Rect(10, 10, 100, 100), "Watch where you're going!") {
isColliding = false;
}
}
}
You'd have to remember to set the isColliding variable to false in some Start() function, and set it to be true when a collision is entered. Haven't tested this out, this is all off the top of my head.
Your answer
Follow this Question
Related Questions
player picture 2 Answers
Struggling to make a Dialogue system,Struggling with creating a Dialogue System 3 Answers
Having trouble with GUI box 0 Answers
Enemy Health, Player Damage 0 Answers
Disable and hide object after collision between player and cube 1 Answer