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. Dismiss Notice

error CS1001

Discussion in 'Scripting' started by akumunoodle, Dec 12, 2020.

  1. akumunoodle

    akumunoodle

    Joined:
    Dec 10, 2020
    Posts:
    1
    Hello! I've recently gotten into coding and I've been following Brackeys' YouTube Unity Tutorial, and after I've completed everything the tutorials have said to do I've been getting error CS1001 (aka "Identifier expected") after I saved and reopened the files/Unity. I have zero idea what I'm doing wrong, so I was hoping someone could help me out

    using UnityEngine;

    public class PlayerObkectCol : MonoBehaviour
    {
    public PlayerMovements movements;

    void OnCollisionEnter(Collision collisionInfo)
    {
    if (collisionInfo.collider.tag == "Obstacle")
    {
    movements.enabled = false;
    FindObjectOfType<GameAdmin>().EndGame();
    }
    }
    }


    Here's my code, and Unity says the problem with line 7 (aka the line below this sentence)
    void OnCollisionEnter(Collision collisionInfo)
    If anyone could help me out it's much appreciated!
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,833
    That doesn't seem to make sense. Try posting the entire error message? Maybe there's a clue in there.

    Just to check, make sure you copy-pasted your code exactly as it appears in your actual project--if you "paraphrase" your code, you sometimes accidentally hide the original error. (Also, use the forum's code tags--there's a button for it towards the right side of the editing bar. These will preserve white space, add line numbers, and do syntax highlighting.)
     
  3. graphioux

    graphioux

    Joined:
    May 3, 2022
    Posts:
    1
    I got the same error too bruh
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,769
    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.

    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.
     
    Last edited: May 3, 2022
    angrypenguin likes this.