How to randomize the correct choice

I’ll explain a little better. I’m making a text style game and what I want is for there to be a random, “right” choice. At the end, there are three doors and only one is the way out. I want the correct choice to change every playthrough. So it’s not the same door every time and it requires a little luck on the players part. I’m new to Unity3d but tried every way that I thought would work, but with no luck. So any help would be appreciated! Thanks. :smiley:

You need to call a Random number generator in your code. That generates a random number.

In your case… 1 2 or 3.

Use Random.Range. Just note that the range is min [inclusive] to max [exclusive]. So to get a 1, 2 or 3, you would set min to 1 and max to 4.

int correctDoor = Random.Range(1, 4);