I have one class that is an arrows class, which upon MouseDown returns a bool true, this is then sent to a cardmechanics code that effects the status bars. However, the bool only seems to work when it is false, but the true never actually gets set to true. I tested to make sure the Arrows did indeed return True but in CardMechanics and the effected StatusBars nothing happens. Only when false.
void OnMouseDown ()
{
if (gameObject.CompareTag("LeftArrow"))
{
leftChoice = true;
Debug.Log("The true statement inside of the home class is working.");
}
if (gameObject.CompareTag("RightArrow"))
{
rightChoice = true;
Debug.Log("The false statement inside of the home class is working.");
}
}
This is the arrows code, the debug log is just to tell me that it is recognizing the if statement.
if (GameObject.FindWithTag("Card") == null)
{
randomnumberpicker = Random.Range(1, 5);
Debug.Log(randomnumberpicker);
if(randomnumberpicker == 1)
{
ZombieCard1 = Instantiate(Resources.Load("Frontcard1")) as GameObject;
ZombieCard1.transform.Translate(0, -1, 0);
if (arrows.leftChoice == true)
{
statusBars.healthBar += 6f;
Debug.Log("The if statement is working.");
}
if (arrows.rightChoice == true)
{
statusBars.healthBar += 6f;
}
}
This is the if statement that should be affected by the bool, it should change the statusbars.health bar to 6.
{
if (healthBar == 6)
{
Debug.Log("Healthbar reached 6");
}
above is the code I have for the Healthbar, on Awake it is set to 0. Any help would be greatly appreciated, again the problem is that the Bool in CardMechanics works when set to false but never when set to true. I am also very new to programming so any tips regarding code would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire