Pretty sure i took a messy shortcut, but I got it to work at least!

 switch (level)
        {            
            case 1:
                int index = Random.Range(0, level1Passwords.Length);
                password = level1Passwords[index];
                break;
            case 2:
                int index1 = Random.Range(0, level2Passwords.Length);
                password = level2Passwords[index1];
                break;
            case 3:
                int index2 = Random.Range(0, level3Passwords.Length);
                password = level3Passwords[index2];
                break;
            default:
                Debug.LogError("Invalid level number");
                break;
        }

I just created new local variables to make it work. I’m sure there is a much cleaner way to do this.

Oh, that was the answer from the video. Lol, yay!

Privacy & Terms