Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

error CS1002: ; expected

Discussion in 'Scripting' started by mrlouise3, Jan 11, 2019.

  1. mrlouise3

    mrlouise3

    Joined:
    Jan 11, 2019
    Posts:
    3
    Still haven't found the error, looks like all have their own semicolon.
    Assets\Scripts\Piece.cs(13,31): error CS1002: ; expected

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Piece : MonoBehaviour
    6. {
    7.     public bool isWhite;
    8.     public bool isKing;
    9.  
    10.     public bool ValidMove(Piece[,] board, int x1, int y1, int x2, int y2)
    11.     {
    12.         //If moving on top of another piece
    13.         If(board[x2,y2]!=null)
    14.             return false;
    15.  
    16.         int deltaMove = Mathf.Abs(x1 - x2);
    17.         int deltaMoveY = y1 - y2;
    18.  
    19.         if(isWhite||isKing)
    20.         {
    21.             if(deltaMove==1)
    22.             {
    23.                 if(deltaMoveY==1)
    24.                     return true;
    25.             }
    26.             else if(deltaMove==2)
    27.             {
    28.                 if(deltaMoveY==2)
    29.                 {
    30.                     Piece p = board[(x1+x2)/2, (y1+y2)/2];
    31.                     if(p !=null && p.isWhite != isWhite)
    32.                         return true;
    33.                 }
    34.             }
    35.         }
    36.      
    37.         if(!isWhite||isKing)
    38.         {
    39.             if(deltaMove==1)
    40.             {
    41.                 if(deltaMoveY==-1)
    42.                     return true;
    43.             }
    44.             else if(deltaMove==2)
    45.             {
    46.                 if(deltaMoveY==-2)
    47.                 {
    48.                     Piece p = board[(x1+x2)/2,(y1+y2)/2];
    49.                     if(p !=null && p.isWhite != isWhite)
    50.                         return true;
    51.                 }
    52.             }
    53.  
    54.             return false;
    55.         }
    56.     }
    57. }
     
  2. Thibault-Potier

    Thibault-Potier

    Joined:
    Apr 10, 2015
    Posts:
    149
    line 13 : " If " instead of if (capital letter ! )
     
  3. mrlouise3

    mrlouise3

    Joined:
    Jan 11, 2019
    Posts:
    3
    Omg, wasted 1hr in this. Thanks! :D
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,091
    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.
     
  5. mrlouise3

    mrlouise3

    Joined:
    Jan 11, 2019
    Posts:
    3
    Yes it does but sometimes it ain't specific therefore gave me some troubles lol.
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,061
    Look closely at the error you first posted:

    Code (CSharp):
    1. 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.