Skip to main content
Bumped by Community user
Bumped by Community user
Added tags, removed numerical-methods, which is not relevant to this case
Link
DMGregory
  • 141k
  • 23
  • 258
  • 401
Source Link

Creating a random lottery system

I would like the game to give all 16 characters (15 NPC + 1 player) a number: 1-16. This number stays the same no matter what and is unique only to that character so two characters cannot have the same number. At a point in the game, the character presses a button.

I need this button to generate a random number and load a scene based on the number. Example: Player's pre-determined number is "8", if the number generator generates an "8" as well, it would load the next scene (where the player has to run away from a mob) If the generator generates anything else other than "8" It will load a different scene (where the player chases an NPC)

Just to clear it up if the number generator generates 1-7 or 9-16 it will load the same scene no matter what. (Getting "9" from the generator would load the same scene as "2" would. Only when "8" is generated, would there be a separate scene)

I'm still incredibly new to Unity and coding in general, so a brief summary of what each line of code is doing would be majorly appreciated! (but not at all demanded!)

I'm most comfortable with C# so if you could have the code in that would be great!