Couldn't get it

As the title says, I couldn’t get it. It’s kind of frustrating because I’ve taken C++ in school and I’m in the middle of the Num wizard UI in the 2D course so I had some basic C# experience. It’s pretty frustrating. What I tried doing was turning input in a global variable and removing it as parameters for the functions since I already created it higher up. Then add the password as if statements in the start game function. That ended up breaking the code. I tried putting the parameters back and keeping the global variable; but that not only worked, it crashed unity on startup. At one point it even crashed my computer and i had to force it off. I felt like I was close but was missing something important. It just gets frustrating and makes me think programming isn’t for me.

Update: I tried again. This time putting the code in the On user input function and making a nested if statement.


        if(currentScreen == Screen.Password && level == 1)
        {
            if(input == "mars")
            {
                Terminal.WriteLine("Access Granted...");
            }
            /*else
            {
                Terminal.WriteLine("Acess Denied..");
            }*/
        }

But I had ti comment out the else because it would always make it denied before I could make the input. I feel like I’m closer so I may give it one more try before getting the answer.

I’m not sure why the ‘else’ isn’t working. However, this code either needs to be in the OnUserInput() function, or preferably in a function called from it. In that way, input doesn’t need to be a global/member variable, because it’s all within the OnUserInput() function. Making ‘input’ global must be preventing it working as expected, I think. Good luck!

Privacy & Terms