Hunger and Thirst system

Hello guys, I’m kinda newbie in Unity scripting, but I’m already reading all the tutorials I can to create my game… Everything went well so far, but then I tried to make my first code ever: a hunger script… I have the theory but I don’t know how to put it in codes!

My idea was setting an “int” var to the player, named “Hunger”, and set it a initial value like 10 or something like that
So there would be an infinite loop that updates every minute or more (I think in this case I would use WaitForSeconds to set the time between each update, but I’m not sure please help me)… everytime this loop updates, it would subtract 1 from the Hunger variable, to do this I think I would use something like this:

if (hunger >= 1);
    WaitForSeconds(60);
    hunger -= 1;

Anyway, guys, I’m kinda lost here, I don’t even know where to start, so please help me here D:
I’m a complete newbie but I wanna learn so if you guys reply with your codes please tell me how it works so I can learn from it

Use InvokeRepeating.

–Eric

You need to be more specific ‘-’

Sorry but no, he doesnt. Even if you are a “noob” doesnt mean that you cant look at the documentation/Scripting Reference for yourself! http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.InvokeRepeating.html

Okay, I went there and tried to create the code, but all I could do was this:

var hunger : float;

function Start() {
	var hunger = 10;
}

function Update() {
	InvokeRepeating("Starve", 1, 60);
	}
	
function Starve() {
	if (hunger >= 1 || hunger <= 10) {
		var hunger - 1;
		}
	}

Is it wrong? If it is, what should I fix in it?

Nevermind, I did it! \O/