In section 2 lecture 20 around the 8 minute mark:
After adding in the code for rounding purposes
Max = Max + 1;
Unity states “All compiler errors have to be fixed before you can enter playmode!”
Can anyone tell me what I am doing wrong? I followed the lecture video exactly.
Here is the code:
text 1.12 KB
using UnityEngine;
using System.Collections;
public class NumberWizard : MonoBehaviour {
// Use this for Initialization
int max = 1000;
int min = 1;
int guess = 500;
// Use this for initialization
void Start () {
max = max + 1; // ADDED THIS CODE IN and now have issues
print ("Welcome to Number Wizard");
print ("Pick a number in your head, dont tell me!");
int max = 1000;
int min = 1;
print ("The highest number you can pick is " + max);
print ("The lowest number you can pick is " + min);
print ("Is the number higher or lower than " + guess);
print ("Up = higher, down = lower, return = equal");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
//print("Up arrow pressed");
min = guess;
guess = (max + min) / 2;
print ("Higher or lower than " + guess);
} else if (Input.GetKeyDown(KeyCode.DownArrow)) {
//print("Down arrow pressed");
max = guess;
guess = (max + min) / 2;
print ("Higher or lower than " + guess);
} else if (Input.GetKeyDown(KeyCode.Return)) {
print ("I won!");
}
}
}