I’m quite new to unity and coding in general. The If Statement in the picture seem straight forward to me but the console keep giving me the “Task Complete” debug note.
Even though the “progress” is not more or equal to “maxProgress” the code below it seem to activate anyway.
I also try put debug note in the “else if” area. It apparently also active at the same time.
What am I doing wrong?
N.B., the opposite of
<, so if you have the following conditional
if (a >= b)
then a single
else statement will capture the condition
a < b. In other words you don’t need to
else if in this case, because the law of the excluded middle says that exactly one of the following must be true:
a >= b,
a < b.
To debug your code, before your conditional block, add the following code:
Debug.Log("Progress is: " + progress + ". maxProgress: is " + maxProgress);
This will determine whether or not you are setting
progress at all.
make sure that you are setting the two variables in the Start() function to 0.0f and 100.0f.
This will make sure nothing is messed up in the unity editor
Try a debug in the else if(), to see if it throws you anything.