Okay so Dragon Ball reference aside, I had a go with the number wizard UI recently, and I seem to not be able to understand the random inclusion. My random variable can go above 1000 (between 1000 and 1004). My values are as follows:
Min is: 1
Max is: 1000
Code is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class NumberWizard : MonoBehaviour
{
// Initialiase varialbles
[SerializeField] int max;
[SerializeField] int min;
[SerializeField] TextMeshProUGUI guessText;
int guess;
// Start is called before the first frame update
void Start()
{
StartGame();
}
//new Function to start a game
void StartGame() {
nextGuess();
//max += 1;
}
public void OnPressHigher() {
min = guess +1;
nextGuess();
}
public void OnPressLower() {
max = guess -1;
nextGuess();
}
void nextGuess() {
//guess = (max+min)/2;
guess = Random.Range(min, max+1);
guessText.text = guess.ToString();
}
}
Thanks for the help!
Just to add onto the above, I get to 1000, but if I keep pressing up, I can get to 1001, 1002, 1004, and thats the highest. I think in the video it shows it stops at 1000?