I cant compile

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

    }

   void Start()
{
    Debug.Log("Welcome to number wizard, yo");
    Debug.Log("G'day mate, welcome to numba wiz-ud...");
    Debug.Log("Pick a number, don't tell me what it is...");
    Debug.Log("The highest number you can pick is: " + max);
    Debug.Log("The lowest number you can pick is: " + min);
    Debug.Log("Tell me if your number is higher or lower than 500");
    Debug.Log("Tell me if your number is higher or lower than: " + guess);
    Debug.Log("Push Up = Higher, Push Down = Lower, Push Enter = Correct");
    max = max + 1;
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        Debug.Log("Up Arrow key was pressed.");
        min = guess;
        Debug.Log(guess);
        guess = (max + min) / 2;
        Debug.Log("Is it higher or lower than..." + guess);
    }
    else if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        Debug.Log("Down Arrow key was pressed.");
        max = guess;
        Debug.Log(guess);
        guess = (max + min) / 2;
        Debug.Log("Is it higher or lower than..." + guess);
    }
    else if (Input.GetKeyDown(KeyCode.Return))
    {
        Debug.Log("You hit enter.");
        Debug.Log("I am a genius!");
    }
}
}

Hi,

Looks like you have a few issues with the braces ({ and }) going on, as well as missing the class definition at the top of the script.

You would typically have something looking more like this;

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

public class NumberWizard : MonoBehaviour
{
    void Start()
    {
        Debug.Log("Welcome to number wizard, yo");
        Debug.Log("G'day mate, welcome to numba wiz-ud...");
        Debug.Log("Pick a number, don't tell me what it is...");
        Debug.Log("The highest number you can pick is: " + max);
        Debug.Log("The lowest number you can pick is: " + min);
        Debug.Log("Tell me if your number is higher or lower than 500");
        Debug.Log("Tell me if your number is higher or lower than: " + guess);
        Debug.Log("Push Up = Higher, Push Down = Lower, Push Enter = Correct");
        max = max + 1;
    }

	// Update is called once per frame
	void Update()
	{
		if (Input.GetKeyDown(KeyCode.UpArrow))
		{
			Debug.Log("Up Arrow key was pressed.");
			min = guess;
			Debug.Log(guess);
			guess = (max + min) / 2;
			Debug.Log("Is it higher or lower than..." + guess);
		}
		else if (Input.GetKeyDown(KeyCode.DownArrow))
		{
			Debug.Log("Down Arrow key was pressed.");
			max = guess;
			Debug.Log(guess);
			guess = (max + min) / 2;
			Debug.Log("Is it higher or lower than..." + guess);
		}
		else if (Input.GetKeyDown(KeyCode.Return))
		{
			Debug.Log("You hit enter.");
			Debug.Log("I am a genius!");
		}
	}
}

Note, the above is using your code, but with the class definition in place at the top and tidies up the indenting for readability. Iā€™m assuming the class is still called NumberWizard in the updated version of the course, but you should probably check to avoid any other issues.

Classnames much match their filename within Unity, so for a class called NumberWizard the filename would need to be NumberWizard.cs.

Hope this helps :slight_smile:

1 Like

Thanks :blush:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms