Search Unity

Error CS1513 } expected

Discussion in 'Windows' started by SmellyDogs, Sep 16, 2013.

  1. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    This error is unique to when I build for the Windows Store platform.
    Unity bug?
     
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,420
    No, programmer bug. You have a missing } somewhere.
     
    Halabadushkeys likes this.
  3. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    Most definately NOT a programmer bug. The same code runs fine for PC/Web builds, but when its targets to Windows store it fails.
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    1,960
    Can you show the code?
     
  5. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class Tank : MonoBehaviour
    6. {  
    7.     public Transform turret;
    8.    
    9.     private EntityUpdate update;
    10.     private float height = 1.1f;
    11.     private bool firing = false;
    12.     private Vector3 enemyPos;
    13.    
    14.     // Use this for initialization
    15.     void Start ()
    16.     {
    17.  
    18.     }
    19.    
    20.     // Update is called once per frame
    21.     void Update ()
    22.     {
    23.         if (update == null) return;
    24.                        
    25.         Vector3 pos = new Vector3(update.Position.x, update.Position.y, update.Position.z);
    26.                
    27.         Vector3 lerp = Vector3.Lerp(transform.parent.position,
    28.                                     pos,
    29.                                     Time.deltaTime);
    30.        
    31.         float y = Terrain.activeTerrain.SampleHeight(lerp) + height;
    32.        
    33.         //RaycastHit hit;
    34.         //if (Physics.Raycast(transform.position, -transform.up, out hit))
    35.         //{
    36.         // 
    37.         //}
    38.  
    39.         transform.parent.position = new Vector3(lerp.x, y, lerp.z);
    40.        
    41.         Vector3 a = new Vector3(transform.parent.position.x, update.Position.y, transform.parent.position.z);
    42.         Vector3 b = new Vector3(update.Position.x, update.Position.y, update.Position.z);
    43.        
    44.         Vector3 target = a - b;
    45.                
    46.         transform.parent.forward = Vector3.RotateTowards(transform.parent.forward, target, 0.1f, Time.deltaTime);  
    47.  
    48.         Quaternion q = Quaternion.AngleAxis(update.WeaponRotation, Vector3.up);
    49. turret.transform.forward = q * Vector3.forward;
    50.     }
    51.    
    52.    
    53.     public void EntityUpdate(EntityUpdate update)
    54.     {
    55.         this.update = update;
    56.        
    57.         if (update.Update_Type == EntityUpdateType.Fire)
    58.         {
    59.             firing = true;
    60.         }
    61.     }  
    62. }
    63.  
    64.  
    The error is on this line:

    Quaternion q = Quaternion.AngleAxis(update.WeaponRotation, Vector3.up);
     
  6. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    Sorry can't edit my post for some reason but error is on line 47.
    I am using MonoDevelop that comes with Unity btw.
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    1,960
    So what throws the error - MonoDevelop or Unity Editor?
     
  8. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    The error comes in the Editor console when I run a build. It lets me run the game in editor just not letting me build it.
     
  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    1,960
    Hmph, any chance for a repro project, from the source file, I don't see nothing :/
     
  10. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    There are a lot of scripts and assets, I can try to strip it down. Where do I send it to?
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
  12. Phil-AV

    Phil-AV

    Joined:
    Jul 9, 2012
    Posts:
    57
    I've got a niggling suspicion that there's a #define going wrong somewhere, hence why it only complains when building for that particular platform.
     
  13. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    490
    I have the same issue, did you find any solution?

    [EDIT:] found it for me!
    I work on a Windows and a Mac PC to build for different plattforms. To do so I simply copy the project from one pc to the other. However, Monodevelop somehow gone crazy on the line endings. I didn't found out what exactly was the problem, but if you delete all line endings close to the line given in the error message the code will compile.
     
    Last edited: Apr 10, 2014
  14. Diego2160

    Diego2160

    Joined:
    Apr 27, 2019
    Posts:
    2
    alguem me ajuda, ta falando que esta tendo um erro CS1513
     
  15. Diego2160

    Diego2160

    Joined:
    Apr 27, 2019
    Posts:
    2
    esse é o comando
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerMoviment : MonoBehaviour
    6. {
    7. // Vetor responsavel pelo movimento
    8. Vector3 movement;
    9. // Responsavel pela transicao da animacao
    10. Animator anim;
    11. // Responsavel pela fisica do objeto
    12. Rigidbody playerRigidbody;
    13. // floor mask
    14. int floorMask;
    15. // Inf para raycast
    16. float camRayLenght = 100f;
    17. void Awake()
    18. {
    19.    
    20.      floorMask = LayerMask.GetMask("Floor");
    21.  
    22.      anim = GetComponent <Animator> ();
    23.      playerRigidbody = GetComponent <Rigidbody> ();
    24.  
    25.   }
    26.  
    27. void FixedUpdate ()
    28. {
    29.      float h = Input.GetAxiaRaw ("Horizontal");
    30.      float v = Input.GetAxiaRaw ("Vertical");
    31.  
    32.      Move (h,v);
    33.      Turning(h,v);
    34.      Animation(h,v);
    35.  
    36. }
    37.  
    38.  
    39. void Move (float h, float v)
    40. {
    41.      movement.Set(h,0f,v);
    42.  
    43.      movement = movement.normalized * speed * Time.deltaTime;
    44.  
    45.      playerRigidbody.MovePosition (transform.position + movement);
    46.  
    47. }
    48.  
    49.  
    50. void Turning()
    51. {
    52.     Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
    53.  
    54.     RaycastHit floorHit;
    55.  
    56.     if(Physics.Raycast(camRay,out floorHit,camRayLength,floorMask))
    57.     {
    58.         Vector3 playerToMouse = floorHit.point - transform.position;
    59.         playerToMouse.Y = 0f;
    60.  
    61.         Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
    62.         playerRigidbody.MoveRotation(newRotation);
    63.    
    64.    
    65.     }
    66.  
    67.  
    68. }
    69.  
    70. void Animating(float h, float v)
    71. {
    72.      bool walking = h != 0f || v!=0f;
    73.      anim.SetBool("IsWalking", walking);
    74.  
    75. }
     
  16. SirMoneeN

    SirMoneeN

    Joined:
    May 10, 2019
    Posts:
    1
    Thanks i found the missing } thanks to you
     
  17. galbr143

    galbr143

    Joined:
    Jun 25, 2019
    Posts:
    1


    Hi. I have the same problem and i am using visual studio with unity and the problem is with the code i wrote in visual studio and i dont find the problem. please help.




    upload_2019-6-25_17-36-54.png
     
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
    You have double opening brace after Start method.
     
  19. maxrendu84

    maxrendu84

    Joined:
    Sep 8, 2019
    Posts:
    1
    when I put "}" where I am asked to, it tells me to put it two spaces further.