Why is my script not taking input from the console?[PLEASE HELP]

I decided to try the Extra Credits for the number wizard suggested after section 2[Ask the user for the range]. After looking up in google(for a long time) I wrote the attached script , but the console is not able to take the input . Can you guys please help me.
=========>
int min, max, guess;

// Use this for initialization
void Start () 
{    
    StartGame();
}

void StartGame()
{
//min = 1;
//max = 1000;

    print ("========================");
    print("Welcome to Number Wizard");
    //print("Pick a number in your head, but don't tell me!");

    print ("Enter a Min number >= "+int.MinValue+".");
    string UserMin = Input.inputString;
    bool res = int.TryParse(UserMin, out min);
    if(res==true)
        print ("Entered Min Value is : "+min);
    else
        print ("Invalid String was entered.");
    
    
    print ("Enter a Max number <= "+int.MaxValue+".");
    string UserMax = Input.inputString;
    res = int.TryParse(UserMax, out max);
    if(res==true)
        print ("Entered Max Value is : "+max);
    else
        print ("Invalid String was entered.");
    
    print("Pick a number between "+min+" and "+ max);
    
    NextGuess();
    //max += 1;
    //print("Up Arrow = Higher, Down Arrow = Lower, Return = Equal.");
}

// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.UpArrow))
{
min = guess;
NextGuess();
}
else if(Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
NextGuess();
}
else if(Input.GetKeyDown (KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
{
print(“I WON!!!”);
StartGame ();
}
}

void NextGuess()
{
    //guess = (min + max)/2;
    guess = (max - min +1)/2;
    print ("Is the number higher or lower than "+guess+" ?");
    print("Up Arrow = Higher, Down Arrow = Lower, Return = Equal.");
}`
1 Like

That last else if isn’t really doing anything…

For the capturing of a value you will need to add a text box onto the screen. Think about how you got the labels to display the text on the canvas.

Hey @Harsha61896, can this topic be marked as [Solved] now?

Privacy & Terms