- Home /
Question by
Jayden_Widmer · Aug 13, 2021 at 03:03 AM ·
c#characterunityeditorchooseselections
Variable won't update (C#, Unity)
I'm trying to make a game with the beginning scene a character selection list. There's also a start button, but I only want it to work if the player selected a player character. The code above is how I'm trying to do it but when I click the start button it always does nothing, even after I clicked on a character. Some help would really be appreciated, thanks! This is my code:
private CharacterSelections chal;
public bool CharacterSelect = false;
public void ClickCharacter()
{
CharacterSelect = true;
}
public void StartGame()
{
if (chal == true)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}
Comment
You are never setting chal to true...i think that might be the problem
Answer by mak431020 · Aug 15, 2021 at 10:47 AM
Because chal is not a bool
public void StartGame()
{
if (CharacterSelect == true)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Velocity for movement 0 Answers
Are unity objects ID is static in project? 1 Answer
No Monobehaviour scripts in files 1 Answer