- Home /
Random.Range with standard numeric?
Creating a number guessing game number range is 1 to 1,000,000, I've declared integers max and min as 1000000 and 1 respectively, I've got another one called guess which is set to 500000.
I've got it printing to the console currently so it looks like this: int max; int min; int guess;
void Start () {
StartGame();
}
void StartGame() {
max = 1000000;
min = 1;
guess = 500000;
print ("Hi! You are about to embark on a non-epic adventure to try and best me! Let me tell you, you won't win, it's physically impossible...");
print ("The coder doesn't even remember how to code a winning mechanic... That's why he started the course over... Plus he needed to learn the basics again." );
print ("So anyways, pick a number between " + min + " and " + (max.ToString("n0")));
print ("Press up if your number is higher, and down if it's lower, hit enter if I got it right.");
print ("Is the number higher or lower than " + (Random.Range (min, max)) + "?");
}
The only thing I want need to know is how can I apply the random.Range with the ToString to create standard numeration? Or would I have create a whole other class to do this? (Extremely new to programming so I've been setting challenges for myself and so far this is one of the best I've come across. So have mercy please.)
For reference I am trying to make it say:
Is the number higher or lower than ddd,ddd?
D being an unknown amount for the system to decide.
sorry but the question isn't clear for me. what you wrote seems right. the problem is with the number format?
Sorry what do you mean by standard numeration? What is the output now, and what do you want it to be?
Answer by Paul-Sinnett · May 06, 2015 at 01:18 PM
Random.Range (min, max).ToString("N0")
N means standard number and 0 means 0 decimal places.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Is Random.Range() Really Maximally Inclusive? 4 Answers
Image for a quarter of a second 1 Answer