----I WRITED MY CODE ON SPANISH WORDS, SORRY, MAYBE SOMEONE CAN HELP ME----
I am making a zombie shooter game, but i want to make 3 variables that have to be:
Hambre = Hunger (im translating the words)
Infeccion = infection
Sed = Thirst (all 3 must be integrers)
but i have the problem that the variables do not get subtracted by “1” every certain time
every subtract acction i putted it on “start” function… soo, here is my code whit the error:
//GUI TEXTURAS
var guihambre:GUIText;
var guised:GUIText;
var guiinfeccion:GUIText;
//NUMEROS ENTEROS
var hambre:int;
var sed:int;
var infeccion:int;
var muriendo:int;
//BOOLEANS FALSO VERDADERO
var infectado:boolean;
var sediento:boolean;
var hambriento:boolean;
var accionar:boolean;
//NUMEROS FLOAT
var ratioinfeccion:float;
var ratiohambre:float;
var ratiosed:float;
var ratios:float;
var ratioh:float;
//VARIABLES EXTERNAS
var itemTracker;
//FUNCIONES
function Start () {
accionar=true;
itemTracker = GameObject.FindWithTag("Player").GetComponent(playermotor);
while (true) {
while (infectado==false) yield;
yield WaitForSeconds (ratioinfeccion);
itemTracker.hp-=infeccion;
}
while (true) {
while (hambriento==false) yield;
yield WaitForSeconds (ratiohambre);
itemTracker.hp-=1;
}
while (true) {
while (sediento==false) yield;
yield WaitForSeconds (ratiosed);
itemTracker.hp-=1;
}
while (true) {
while (accionar==false) yield;
yield WaitForSeconds (ratioh);
hambre-=muriendo;
}
while (true) {
while (accionar==false) yield;
Debug.Log("THE SUBTRACTED VALUES ARE WORKING");
yield WaitForSeconds (ratios);
sed-=muriendo;
}
}
function Update(){
guihambre.text=""+hambre+"%";
guiinfeccion.text=""+infeccion+"%";
guised.text=""+sed+"%";
if(hambre<0){
hambre=0;
}
if(hambre>100){
hambre=100;
}
if(hambre==0){
hambriento=true;
}else{
hambriento=false;
}
if(infeccion<0){
infeccion=0;
}
if(infeccion>100){
infeccion=100;
}
if(infeccion!=0){
infectado=true;
}else{
infectado=false;
}
if(sed<0){
sed=0;
}
if(sed>100){
sed=100;
}
if(sed==0){
sediento=true;
}else{
sediento=false;
}
}