So I am fairly new to coding in general. I am messing around with a project trying to make it so whenever I press a button it shows 1 out of the 4 panels. Right now the way I have it setup once one of the panels pops up it stays on forever and it only shows the first panel that popped up. I want to be able to make it so when I click the button it hides all 4 panels then shows the one that got picked from the random roll.
Currently this is my code
public GameObject fireCard;
public GameObject waterCard;
public GameObject holyCard;
public GameObject forestCard;
int troopNumber;
public void ClickTheButton()
{
int troopNumber = Random.Range(1, 4);
if (troopNumber == 1)
{
fireCard.SetActive(true);
}
if (troopNumber == 2)
{
waterCard.SetActive(true);
}
if (troopNumber == 3)
{
holyCard.SetActive(true);
}
if (troopNumber == 4)
{
forestCard.SetActive(true);
}
}
I’ve tried making it so it constantly only picks one and adding the code below, but nothing happens when I click the button.
if (troopNumber == 1)
{
fireCard.SetActive(false);
fireCard.SetActive(true);
}