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.

Assets\MouseLook.cs(29,62): error CS1003: Syntax error, ',' expected

Discussion in 'Scripting' started by EpikKatzGames, Jan 16, 2021.

Thread Status:
Not open for further replies.
  1. EpikKatzGames

    EpikKatzGames

    Joined:
    Dec 10, 2020
    Posts:
    5
    Im new to unity and I used this script and this error poped up

    Assets\MouseLook.cs(29,62): error CS1003: Syntax error, ',' expected

    This is my script

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class MouseLook : MonoBehaviour
    6. {
    7.  
    8.     public float mouseSensitivity = 100f;
    9.  
    10.     public Transform playerBody;
    11.  
    12.     float xRotation = 0f;
    13.    
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.         Cursor.lockState = CursorLockMode.Locked;
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    24.         float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
    25.  
    26.         xRotation -= mouseY;
    27.         xRotation = Mathf.Clamp(xRotation, -90f, 90f);
    28.  
    29.         transform.localRotation = Quaternion.Euler(xRotation 0f, 0f);
    30.         playerBody.Rotate(Vector3.up * mouseX);
    31.     }
    32. }
     
  2. EpikKatzGames

    EpikKatzGames

    Joined:
    Dec 10, 2020
    Posts:
    5
    If anyone can help me please
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    You see the error? You see the line number 29? Do you see anything missing in line 29, like maybe a comma the way that the error message tells you?
     
    Bunny83 likes this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    Also, what is with the duplicate posts?! Just edit your previous post, the one I already responded to.
     
    Bunny83 likes this.
  5. EpikKatzGames

    EpikKatzGames

    Joined:
    Dec 10, 2020
    Posts:
    5
    on im sorry im new I diden't know I could edit it
     
  6. EpikKatzGames

    EpikKatzGames

    Joined:
    Dec 10, 2020
    Posts:
    5
    I added a comma after xRotation (is it supposed to go there) and it responded with this error

    Assets\MouseLook.cs(12,22): error CS1001: Identifier expected
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    in line 29 it is.

    did you add a comma also in line 12? because that's not a thing, that does not make sense.

    look, rather than me playing remote one-character-at-a-time proofreader, just go back and get 100% of the spelling, capitalization and punctuation just right from wherever you got this. 100% of it has to be correct for any of it to work.
     
  8. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,277
    Errors are there to help you. It's a good idea to try and learn how to understand them. Try to apply the breakdown in this post of your original error to the new error you're receiving. If you don't understand a word, don't just gloss over it. Ask what the word means here, or research it elsewhere. Cultivating a habit of research will pay dividends for you in every part of your coding journey.

    Here's a breakdown of your specific error, but try applying this process to any other error you may encounter as well:

    This section of the error is the prefix, and the format is standard across all messages:

    Assets\MouseLook.cs(29,62)
    --> The compiler encountered an error at this file:
    Assets\MouseLook.cs
    , at this position (line, column):
    (29,62)


    error CS1003
    --> A technical code that refers to this specific type of error. When in doubt, try googling the code in question (eg. "c# CS1003" or "unity CS1003"). It will probably lead you to a page like this (CS1003), which will provide more context for what the error is and why it occurs. This is a great last resort when trying to figure out why an error is happening. It will also often lead you to a helpful StackOverflow post, or even right back to this forum.

    The rest of the error is the error message itself:

    The error message varies wildly from error to error. For many common errors you will be able to copy paste this section directly into a search engine and find many articles/forum posts/etc. on what it means and why it happens.

    Syntax error
    --> something is wrong with how the code is formatted.

    ',' expected
    --> The compiler was expecting a comma at this location but didn't find one.

    All of the above boils down to this:

    On line 29, you forgot a comma between
    xRotation
    and
    0f
    :
    Code (CSharp):
    1. transform.localRotation = Quaternion.Euler(xRotation 0f, 0f);
     
    Last edited: Feb 23, 2021
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    This was so well put I am going to keep a link to the above post just for times like this.

    LMK if that bugs you in any way and I won't post your link, otherwise, it's in the hopper!

    "Get to the hoppah!"
     
    Homicide, Pursuedmacoroon and Madgvox like this.
  10. Willyilpascuale

    Willyilpascuale

    Joined:
    May 19, 2021
    Posts:
    2
    Help please.

    I was scripting when i found this error:error CS1519: Invalid token '=' in class, struct, or interface member declaration

    thise is the script :/

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class visuale : MonoBehaviour
    {
    public Transform player;
    float sensibilità = 300f;
    float rotazione;

    // Start is called before the first frame update
    void Start()
    {
    Cursor.lockState = CursorLockMode.Locked;
    } Cursor.visible = false
    // Update is called once per frame
    void Update()
    {
    float x = Input.GetAxis("Mouse X") * Time.deltaTime * sensibilità;
    float y = Input.GetAxis("Mouse Y") * Time.deltaTime * sensibilità;
    rotazione -= y;
    rotazione = Mathf.Clamp(rotazione, -60f, 60f);
    transform.localRotation = Quaternion.Euler(rotazione, 0, 0);
    player.Rotate(Vector3.up * x);
    }
    }

    I need help please.
     
  11. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    Do not hijack other people's threads for your problems. It's against forum rules.

    Start your own post. It's FREE!

    Remember: NOBODY memorizes error codes. 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 important parts of an 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)

    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.

    How to report your problem productively in the Unity3D forums:

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

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    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/
     
    zombiegorilla likes this.
  12. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    Please start your own thread.

    How to report your problem productively in the Unity3D forums:

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

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    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/

    Use code tags:
     
  13. akjskjnszj

    akjskjnszj

    Joined:
    Sep 21, 2021
    Posts:
    1
    hi i have error (Assets\look.cs(29,62): error CS1003: Syntax error, ',' expected)



    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class look : MonoBehaviour
    {
    public float mouseSensitivity = 100f;
    public Transform human;
    float xRotation = 0f;
    // Start is called before the first frame update
    void Start()
    {
    cursor.lockstate = cursorlockmode.locked;
    }
    // Update is called once per frame
    void Update()
    {
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);
    transform.localRotation = Quaternion.Euler(xRotation 0f, 0f);
    human.Rotate(Vector3.up * mouseX);
    }
    }
     
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    Please STOP necroposting.

    You are just making fatfinger typos here. You can fix them yourself, here is how:

    Remember: NOBODY memorizes error codes. 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.

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors.

    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)

    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.

    How to do tutorials properly:

    Tutorials are a GREAT idea. Tutorials should be used this way:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly. Fortunately this is the easiest part to get right. Be a robot. Don't make any mistakes. BE PERFECT IN EVERYTHING YOU DO HERE.

    If you get any errors, learn how to read the error code and fix it. Google is your friend here. Do NOT continue until you fix the error. The error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!
     
  15. Honker_dev

    Honker_dev

    Joined:
    Aug 1, 2022
    Posts:
    1
    what do i do about this?

    transform.Rotate(0f, PlayerMouseInput.x, * MouseSensitivity 0f);

    and the error says:
    Assets\scripts\playermovement.cs(49,68): error CS1003: Syntax error, ',' expected
     
  16. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,221
    Same thing: PLEASE ... stop necro posting and stop making typos. You have left out a character. It's pretty friggin' obvious which one. Go back to where you got this.

    Since you clearly completely and totally failed to read this thread before plunking your necro post down, I'll post it again for you.

    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.
    BE PERFECT IN EVERYTHING YOU DO HERE!!


    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!
     
  17. dopepug21

    dopepug21

    Joined:
    Aug 12, 2022
    Posts:
    1
    thank you @Kurt-Dekker for stoping people from hijacking other threads
     
  18. jacob77898

    jacob77898

    Joined:
    Oct 7, 2021
    Posts:
    9
    Guys he is trolling 100%
     
  19. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    8,888
    And like that, your post is a good reason to lock this thread.
     
    Kurt-Dekker likes this.
Thread Status:
Not open for further replies.