I decided to call a function to clean everything up

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class NumberWizard : MonoBehaviour

{

int max = 1000;

int min = 1;

int guess = 500;

// Start is called before the first frame update

void Start()

{

    Debug.Log("Please...");

    Debug.Log("Pick a number between");

    Debug.Log(max + " & " + min);

    Guess();

    max = max +1;

}

// Update is called once per frame

void Update()

{

    //Detect when the up arrow key is pressed down

    if (Input.GetKeyDown(KeyCode.UpArrow))

    {

        Debug.Log("Your number is higher... hmmmm");

        min = guess;

        guess = (max + min) / 2;

        Guess();

    }

    else if (Input.GetKeyDown(KeyCode.DownArrow))

    {

        Debug.Log("Oh... it's lower");

        max = guess;

        guess = (max + min) / 2;

        Guess();

    }

    else if (Input.GetKeyDown(KeyCode.Return))

    {

        Debug.Log("Winner Winner Chicken Dinner Babbbyyyyyyy!!!");

    }

}

void Guess()

{

    Debug.Log("Tell me... is your number is higher or lower than " + guess);

    Debug.Log("Up = Higher, Down = Lower, Enter = Correct");

}

}

update… i just watched the next lesson and realised we do this anyway lol

Privacy & Terms