Search Unity

Resolved Error CS1001

Discussion in 'Getting Started' started by DAS900, Jan 25, 2024.

  1. DAS900

    DAS900

    Joined:
    Jan 25, 2024
    Posts:
    1
    Hello, I get this error, can you help me please?

    (45,22): error CS1001: Identifier expected


    upload_2024-1-25_15-46-1.png
    upload_2024-1-25_15-46-17.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,727
    Sounds like a typo to me!! But there's some really good news...

    You can fix your own typing mistakes. Here's how:

    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.

    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? Are you structuring the syntax correctly? Look for examples!

    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.



    For future reference, if you actually have a real problem...

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

    The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven't put effort into finding the documentation, why should we bother putting effort into replying?



    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    - Do not TALK about code without posting it.
    - Do NOT post unformatted code.
    - Do NOT retype code. Use copy/paste properly using code tags.
    - Do NOT post screenshots of code.
    - Do NOT post photographs of code.

    - Do NOT attach entire scripts to your post.
    - ONLY post the relevant code, and then refer to it in your discussion.
     
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,923
    The error is because you seem to have both
    System.Numerics
    and
    UnityEngine
    name spaces imported, both of which define a
    Vector3
    struct. A assume System.Numerics is unintentional, so I'd just remove that and fix any of the other spelling mistakes.
     
    Ryiah likes this.
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    You have multiple errors in your code. Like @spiney199 mentioned you've added
    System.Numerics
    to the list of using statements and that import has its own versions of
    Vector2
    and
    Vector3
    . Since you want the ones that belong to
    UnityEngine
    just remove the using statement for
    System.Numerics
    on line 3.

    C# is case sensitive. That means it sees
    foo
    and
    Foo
    as different names. With that in mind you've named the update method on line 14
    update
    but Unity will only look for a method named
    Update
    .

    Line 27 refers to a variable named
    targetPos
    but that variable hasn't been defined for the section of code in question.

    Line 37 has
    position
    misspelled as
    positrion
    .

    Line 45 has a
    using
    statement that doesn't belong there or at all.

    Also this thread doesn't really belong in this section as it's a Scripting topic rather than a 2D one. You'll get more and sometimes faster responses if the thread is posted in the section that is most accurate to the topic.
     
    Last edited: Jan 26, 2024
    spiney199 likes this.