Why doesn't this boolean code work=
So I have two scripts, one of them for creating villagers. These villagers are created when I do an action using another script, which works correctly. Problem is, the second script doesn't work, and I don't know why. What I want to do is having two booleans (aumentoAldeanosTotal & aumentoAldeanos), which start as false, to turn true. When they do, the script to add the numbers I set and turn the booleans to false again so the process can be repeated. The booleans are set to true on the two lower functions, but the Update part of the code doesn't work. Anyone know why?
Any help is appreciated.
public void Update() {
if (aumentoAldeanos == true) //NO SE LLAMA
{
Debug.Log("Bool cambiado a true");
numeroCampesinosActivos = numeroCampesinosActivos + 5;
//Debug.Log("Se suman campesinos activos");
aumentoAldeanos = false;
Debug.Log("Se cambia el bool a false");
}
if (aumentoAldeanosTotal == true) //NO SE LLAMA
{
Debug.Log("Bool cambiado a true");
numeroTotalCampesinos = numeroTotalCampesinos + 10;
//Debug.Log("Se suman campesinos totales");
aumentoAldeanosTotal = false;
Debug.Log("Se cambia el bool a false 2");
}
aldeanosText.text = numeroCampesinosActivos + "/" + numeroTotalCampesinos;
}
public void AumentarNumeroTotal()
{
//Debug.Log("Se llama a cambiar el bool a true"); ESTA PARTE SE EJECUTA
aumentoAldeanosTotal = true;
//Debug.Log("Se cambia el bool a true"); ESTO SE EJECUTA SIN IF, CON IF NO SE EJECUTA
}
public void AumentarNumeroCampesinos()
{
// Debug.Log("Se llama a cambiar el bool a true 2"); ESTA PARTE SE EJECUTA
aumentoAldeanos = true;
//Debug.Log("Se cambia el bool a true 2"); ESTO SE EJECUTA SIN IF, CON IF NO SE EJECUTA
}
Your answer
Follow this Question
Related Questions
how to activate a Boolean when Inputfield is not empty ? 1 Answer
Coroutine not working as expected 1 Answer
Speed variable not incrementing per frame (Bug?) 1 Answer
why it speed different? 0 Answers