If my question was a bit vague i'll expand here;
Basically what i want to do is have a little icon of a stomach (To represent hunger) and every frame have a variable that contains the hunger decrease by 0.1. Once the hunger level reaches certain intervals, i want the color to change on the guiTexure, for example; at 500.0f color = yellow at 250.0f color = red
I'm fairly new to scripting in unity, so i could be way off with this code, so can somebody please help me
It will decrease the CurrentHunger variable, however the colors do not change at the intervals.
Here's my code;
A line like this:
is actually testing whether or not x.xxxxxxxxx is exactly equal to 500.0000000 which is a bad way to do things. Even if your logic makes it clear that the if statement should trigger at some point, floating point numbers are not 100% accurate, and so still may not end up exactly the value you expect.
instead, use less-than and greater-than checks:
answered Aug 20 '12 at 07:29 AM