Integer error

Hi,

In section 20, I received an error message what is marked in bold. Which mistake did I do for this bug?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

int max = 1000; a namespace cannot directly contain members such as fields or methods
int min = 1;
int guess = 500;

public class NumberWizard : MonoBehaviour {

// Use this for initialization
void Start () {
	max = max + 1;

	print ("Welcome to the Number Wizard!");
	print ("Pick a number in your head and don't tell me!");

	print ("The highest number you can pick is " + max);
	print ("The lowest number you can pick is " + min);

	print ("Is the number lower or higher than" +guess );
	print ("Up arrow for higher down for lower, return for equal pls.");

}

// Update is called once per frame
void Update () {
	if (Input.GetKeyDown (KeyCode.UpArrow)) {
		min = guess;
		guess = (max + min) / 2;
		print ("Higher or lower than" + guess);

	} else if (Input.GetKeyDown (KeyCode.DownArrow)) {
		max = guess;
		guess = (max + min) / 2;
		print ("Higher or lower than" + guess);
	} else if (Input.GetKeyDown (KeyCode.Return)) {
		print ("I won!");

	}

}
}

Declare the variables inside the class. The only things that go in to the
very top space are compiler directives, like the Using statements, and
other things that are way beyond the scope of… probably just about any
Unity scripting.

Privacy & Terms