Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question error CS0106

Discussion in 'Scripting' started by JuanesPlaza2007, May 4, 2023.

  1. JuanesPlaza2007

    JuanesPlaza2007

    Joined:
    Apr 28, 2023
    Posts:
    5
    hello, I had this error (Assets\Scenes\defaults\scripts\character\characterController.cs(103,6): error CS0106: The modifier 'private' is not valid for this item), and search it in google. I founded that maybe putting the "private..." after the "}", it will work, but it remove the error but the character does not jump. i spend like 30 min searching the way to fix the error, but i have not idea how. I followed the steps that a expert give me in this forum, but i did not found the error. Can someone help me?
    This is my script:
    View attachment 1237759
    View attachment 1237762
    View attachment 1237765
    View attachment 1237768
    thanks
     
  2. berkcanhasanaydin

    berkcanhasanaydin

    Joined:
    Jan 29, 2020
    Posts:
    2
    put a } on line 117
    Edit: To be more clear, its looks like u deleted a curly bracket by accident. Now, your Jump method is in CalculateMovement method. Thats why its throwing error.
     
    Last edited: May 4, 2023
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    You should've continued your discussion on your original thread TBH. Regardless, in the future, please post code using code-tags and not pictures of code.

    Thanks.
     
    JuanesPlaza2007 likes this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,951
    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.