Search Unity

unknown coding error (im new)

Discussion in 'Scripting' started by Manif3st, Jan 9, 2020.

  1. Manif3st


    Jan 9, 2020
    i just started working on a game(my first one) and I've run into a problem after watching a YouTube tutorial. i followed what they did for the code and when i tried ti use it i got a error code. the video is from October 1029, have things changed?

    sorry if this is a basic fix
  2. Hikiko66


    May 5, 2013
    So, you have two types of errors in programming.

    -You have compile time errors (the compiler catches these errors, and it won't compile and run the application until you have fixed these errors)
    -You have runtime errors. The application will compile and run, because the compiler can't catch these errors at compile time, but you will get errors while you are running the application.

    You will want to learn how to fix errors as soon as possible. You can't program without being able to do this, and it will make your life a lot easier not having to rely on other people on a forum for every little error you experience (there will be many). You learn a lot by researching and fixing errors.

    Compile time errors basic tutorial
    If you need more tutorials just search for - Compile Time Errors Unity

    So, the error will stop you from running the application. Unity will ask you to fix all the errors in order to run the application. The errors will show up as red in the debug log in the unity editor. It will have a description of the error and that will tell you the problem and will often suggest a likely fix. It will provide the file name, the line number, and other details. Double clicking the error in the debug log should open up that file in your code editor and jump to the line where the error is thrown. This doesn't necessarily mean that that particular line needs to be modified (though typically it is), it might be a different line that needs to be modified, but the line and the error description will give you clues as to what the problem is.

    Runtime errors basic tutorial - debugging
    If you need more tutorials (perhaps you are using different code editor), just search for -Debugging Unity YourCodeEditor
    Your debugger will depend on your IDE / code editor, but they all have the same fundamental funtionalities

    If you don't understand an error message / description, the first thing you should do is run that message through a search engine and read up on it. Other people will have experienced this error. There will be many forum threads on many forums talking about the error, what it means, why it is being thrown in the context of a piece of code, and how to fix it. Sometimes the error message will contain non generic information like your own custom class names etc. You should remove those from the error message before searching, you only want to search for the generic parts of the error message.

    Asking for help on a forum should be done if you have tried everything else, you have struggled with the problem and you are stuck and not getting anywhere. Struggling with errors is a good learning mechanism, but if you get stuck, at some point, it's better to ask for help. People on a forum expect that you have researched and sufficiently struggled with the error and attempted to resolve it on your own, and have been unsuccessful. That is a fair expectation.

    When asking for help on a forum, you should post the error message, and you should post what you believe is the relevant code that is throwing and contributing to the error. You should use code tags to post your code on the forum so that it is readable as code.
    Last edited: Jan 9, 2020