When I try and run Number Wizard it starts off fine, with a guess of 500 but the second guess is always 0 no matter if I pressed the higher or lower button. I’ve checked the code but can’t find anything wrong, is there anything else that could be the problem?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class NumberWizardScript : MonoBehaviour
{
[SerializeField] int max;
[SerializeField] int min;
[SerializeField] TextMeshProUGUI guessText;
int guess;
// Start is called before the first frame update
void Start()
{
StartGame();
}
void StartGame()
{
guess = (max + min) / 2;
guessText.text = guess.ToString();
max = max + 1;
}
public void OnPressHigher()
{
min = guess;
NextGuess();
}
public void OnPressLower()
{
max = guess;
NextGuess();
}
void NextGuess()
{
guess = (max + min) / 2;
guessText.text = guess.ToString();
}
}