- Home /
Question by
Scrapps · Oct 05, 2014 at 09:31 AM ·
How to make a GUI.box pop up under an if statement (new to programming)
This is pretty self explanatory I keep getting an error message in the code below.
void OnGUI () {
if (playerLives = 0) ------> **Cannot implicitly convert type "float" to "bool"**
{
GUI.Box (new Rect (10, 10, Screen.width - 10, Screen.height - 10), "GAME OVER");
}
}
I know what float and bool are but why doesn't work? I set my =0 to < 1 and <= 0 but neither of these any effect when my playerLives went to 0.
Comment
Answer by chrischu · Oct 05, 2014 at 10:02 AM
You are not using the right operation. See the following examples:
var x = 5; // Value of x is now 5, this is called ASSIGNMENT
if (x == 5) {} // Checks if value of x is 5, this is called COMPARISON
thank you that was a simple fix and a good explanation :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
What does that mean? "BCW0008: WARNING: Duplicate namespace: 'UnityEngine'" 1 Answer
How to make enemy slowly run to player 1 Answer
How to add play again or quit dialog 1 Answer
CS0029 convert type 1 Answer