error CS1002: ; expected

Still haven’t found the error, looks like all have their own semicolon.
Assets\Scripts\Piece.cs(13,31): error CS1002: ; expected

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Piece : MonoBehaviour
{
    public bool isWhite;
    public bool isKing;

    public bool ValidMove(Piece[,] board, int x1, int y1, int x2, int y2)
    {
        //If moving on top of another piece
        If(board[x2,y2]!=null)
            return false;

        int deltaMove = Mathf.Abs(x1 - x2);
        int deltaMoveY = y1 - y2;

        if(isWhite||isKing)
        {
            if(deltaMove==1)
            {
                if(deltaMoveY==1)
                    return true;
            }
            else if(deltaMove==2)
            {
                if(deltaMoveY==2)
                {
                    Piece p = board[(x1+x2)/2, (y1+y2)/2];
                    if(p !=null && p.isWhite != isWhite)
                        return true;
                }
            }
        }
      
        if(!isWhite||isKing)
        {
            if(deltaMove==1)
            {
                if(deltaMoveY==-1)
                    return true;
            }
            else if(deltaMove==2)
            {
                if(deltaMoveY==-2)
                {
                    Piece p = board[(x1+x2)/2,(y1+y2)/2];
                    if(p !=null && p.isWhite != isWhite)
                        return true;
                }
            }

            return false;
        }
    }
}

line 13 : " If " instead of if (capital letter ! )

1 Like

Omg, wasted 1hr in this. Thanks! :smile:

Your first if statement is capitalized.

Someone beat me to it. lol.

Visual Studios should be showing you the error line…other programs should have a similar error display I would think.

1 Like

Yes it does but sometimes it ain’t specific therefore gave me some troubles lol.

Look closely at the error you first posted:

Assets\Scripts\Piece.cs(13,31)

That “(13,31)” bit is telling you it’s complaining about line 13, at character 31. In this case the character number isn’t helpful (it’s just complaining about the last character on that line), but being shown it’s related to line 13 was all it took to zero in on the error for me. So, do look at the line number it’s complaining about, as that’s usually pretty reliable.

it is capital lol

I have a code but when I put it I get this: error CS1002:; expected (12, 18)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
    public GameObject jugador;
    public GameObject referencia;
    private Vector3 distancia;

    // Start is called before the first frame update
    void Start ()
        distancia = tranform.position - jugador.transform.position;
    {
       

    // Update is called once per frame
    void LateUpdate ()
        distancia = Quanternion.AngleAxis(Input.GetAxis ("Mouse X") * 2, Vector3.up) * distancia;
       
        transform.position = jugador.transform.position + distancia;
        transform.LookAt (jugador.transform.position);


        Vector3 copiaRotacion = new Vector3(0, transform.eulerAngles.y, 0);
        Referencia.transform.eulerAngles = copiaRotacion;
    }
[INDENT]}[/INDENT]

If this is your full script, your curly brackets do not match up correctly at all. Your Start has no opening bracket before the code and then no closing bracket. Then LateUpdate appears to have a closing without an opening. Then you need to close the class

Hallo, kann mir vielleicht jemand helfen. Ich finde leider den Fehler nicht. Unity zeigt an: ; Expected

Verwenden von System.Collections;
mit System.Collections.Generic;
mit UnityEngine;
Spieler der öffentlichen Klasse: MonoBehaviour
{
öffentliche Schwimmergeschwindigkeit = 1;
öffentlicher Schwimmer JumpForce = 1;
Starrkörper2D starr;
private bool OnCollision;
// Start wird vor dem ersten Frame-Update aufgerufen
void Start()
{
starr = GetComponent();
}
// Update wird einmal pro Frame aufgerufen
void Update()
{
transform.Translate(Input.GetAxis(“Horizontal”) * Geschwindigkeit * Time.deltaTime, 0, 0);
Vector3 moveObject = Vector3.right;
this.transform.position += moveObject * Geschwindigkeit * Time.deltaTime;
if (Input.GetAxisRaw(“Jump”) == 1 && OnCollision == true)
{
zurückgeben speichern Version1;
}
{
rigid.velocity = Vector3.up * JumpForce;
}
}
OnCollisionEnter(Kollisionskollision)
{
OnCollision = true;
}
private void OnCollisionExit(Kollisionskollision)
{
OnCollision = false;
}
}

Sorry, but I don’t know what language this is. To my knowledge you can’t replace c# code with foreign language versions. So “using” can’t be replaced with “mit”.

I might be wrong on that, but even if that would work, I feel like a see a lot of other issues that might interfere.

I have a feeling the user dumped his whole post through google translator or something… I’ve seen this enough times recently that I don’t think that many people are legitimately trying to localize C# keywords.

But hey, I’m open to the possibility. :slight_smile:

Anyway, for success, @Ghostendo , PLEASE stop posting to old threads to fix your own simple typos. If you are following tutorials, you CANNOT MAKE EVEN ONE CHARACTER ERRORS. 100% of the code must be PERFECTLY TYPED. See below.

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 list, 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)

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 understand compiler and other errors and even fix them yourself:

https://forum.unity.com/threads/assets-mouselook-cs-29-62-error-cs1003-syntax-error-expected.1039702/#post-6730855

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

How to use code tags: https://discussions.unity.com/t/481379

Beyond that, here is how to report your problem productively in the Unity3D forums:

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

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.

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!