First of all, I can’t even start counting how many times I tried to do something like this
string myString;
int myInt;
myInt = myString // <---- Error
if (myInt == 10)
{
DoStuff();
}
What always happened was that I got an error (you can’t convert a string into an int. Or vice versa) and I tried to work around it.
But the solution was super easy:
myInt = int.Parse(MyString);
Understanding this is going to save me loads of headackes in the future.
I have been seeing expressions like this for over 5 years, without getting the grasp of it until today.
For me, finally learning that tiny bit of code was another success. This is it:
bool inputlIsValidLevelNumber = (input == "1" || input == "2" || input == "3");
I usually did such things like this:
bool inputIsValidLevelNumber;
if (input == "1" || input == "2" || input == "3")
{
inputIsValidLevelNumber = true;
}
That’s literally 5 times shorter! so to finally understand what that was ^^
edit:
Also! I learned how to save on potential errors by saving on (“cashing”?) an additional variable:
Being:
password = PasswordsLevel_1[Random.Range(0, PasswordsLevel_1.Length)];
Better than
rNum = Random.Range(0, PasswordsLevel_1.Length)
password = PasswordsLevel_1[rNum];