Don't know what I am doing wrong

Hey, anyone know what I am doing wrong here?
Capture|237x114

Hi,

Welcome to our community. :slight_smile:

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

Yes I have, in fact I even copied and pasted it just to check for sure. They are both the same.

Please hover your mouse over OnUserInput. What does the compiler say?

void .OnUserInput(string input), A namespace cannot directly contain members such as fields or methods Sorry for taking a while to respond.

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

Could you please post your entire script here? Maybe there is a misplaced curly bracket somewhere.


See also:

using System.Collections.Generic;
using UnityEngine;

public class Hacker : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
       

        ShowMainMenu("Hello Player", "Nasa", "Steam", "School Computer");
    }
    void ShowMainMenu(string greeting, string HackerHard, string HackerMedium, string HackerEasy)
    {

        Terminal.ClearScreen();
        Terminal.WriteLine(greeting);
        Terminal.WriteLine("");
        Terminal.WriteLine("1: Would you like to hack into the " + HackerEasy);
        Terminal.WriteLine("");
        Terminal.WriteLine("2: Would you like to hack into " + HackerMedium);
        Terminal.WriteLine("");
        Terminal.WriteLine("3: Would you liket to hack into " + HackerHard);
        Terminal.WriteLine("");
        Terminal.WriteLine("Enter the number here:");
    }
}




void OnUserInput(string input)
{
    print(input);
} 

Some of it will look different since I changed some parts up a bit to learn some more by myself.

Your code looks fine except for one misplaced curly bracket. Check if your OnUserInput method part of your Hacker class. Hint: It’s not.

Where is the misplaced bracket?

Directly after the closing curly bracket of the ShowMainMenu method. You can even see that the OnUserInput method is outside your class because you formatted your code properly.

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

Privacy & Terms