- Home /
ANOTHER Boolean Problem
I've got it so that if 2 booleans are true, a print command is run. Here...
var isVolcanoTxtShowing : boolean = false;
var showAgain : boolean = true;
function OnTriggerEnter () {
isVolcanoTxtShowing = true;
}
function OnTriggerExit () {
isVolcanoTxtShowing = false;
}
function OnGUI () {
if(isVolcanoTxtShowing && showAgain){
print("hi there");
showAgain = false;
}
}
What have I done wrong now... >:/
Answer by syclamoth · Oct 30, 2011 at 12:40 PM
The problem here is that you are only printing that once, and only in the first GUI step! Something which would be more useful to you, I think, instead of printing to a log file, would be the GUILayout.
function OnGUI () {
if(isVolcanoTxtShowing && showAgain)
{
showAgain = !GUILayout.Button("Press me to make the message go away");
}
}
Basically, you've done nothing wrong, exactly, but what you have done isn't very useful to you.
I'm loving this new 'bypass the moderation queue entirely' thing. I need to tell the others about this.
Your answer
Follow this Question
Related Questions
How does Unity reads the "If" conditions? 3 Answers
How can I make this only act once? 3 Answers
Is there a simple replacement for a static variable? 2 Answers
Array with boolean variables? 3 Answers
farming game with replanting problem 2 Answers