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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Error CS1513 } expected

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

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

    SmellyDogs

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

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,748
    No, programmer bug. You have a missing } somewhere.
     
  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.
     
    angelperez_unity and M_Gaming like this.
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,247
    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);
     
    abdulraufjalal161 likes this.
  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:
    3,247
    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:
    3,247
    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:
    9,886
  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.
     
    mahnoorcodes likes this.
  13. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    611
    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
    bettsmatthew likes this.
  14. Diego2160

    Diego2160

    Joined:
    Apr 27, 2019
    Posts:
    2
    alguem me ajuda, ta falando que esta tendo um erro CS1513
     
    benjalonpro11 likes this.
  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
     
    Ameenullah likes this.
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    9,886
    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.
     
  20. Areax-games

    Areax-games

    Joined:
    Oct 1, 2019
    Posts:
    1
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Char : MonoBehaviour
    6.  
    7. {
    8.     private float move;
    9.     private float moveSpeed = 3.5f;
    10.     Rigidbody2D rb;
    11.     SpriteRenderer sprite;
    12.     Animator animationPlayer;
    13.     private bool Jumping;
    14.     private float jumpSpeed = 5f;
    15.     public Transform feetPosition;
    16.     public float sizeRadius;
    17.     public LayerMask whatIsGround;
    18.     public bool isGrounded;
    19.  
    20.     // Start is called before the first frame update
    21.     void Start()
    22.     {
    23.         rb = GetComponent<Rigidbody2D>();
    24.         sprite = GetComponent<SpriteRenderer>();
    25.         animationPlayer = GetComponent<Animator>();
    26.     }
    27.  
    28.  
    29.     void Update()
    30.     {
    31.         {
    32.             //Reconhecer o chão
    33.             isGrounded = Physics2D.OverlapCircle(feetPosition.position, sizeRadius, whatIsGround);
    34.             move = Input.GetAxis("Horizontal");
    35.             if (move < 0)
    36.  
    37.                 sprite.flipX = true;
    38.  
    39.             else if (move > 0)
    40.  
    41.                 sprite.flipX = false;
    42.  
    43.             if (Input.GetButtonDown("Jump") && isGrounded == true)
    44.  
    45.                 Jumping = true;
    46.  
    47.  
    48.  
    49.             if (isGrounded)
    50.                 animationPlayer.SetBool("Walking", true);
    51.             else
    52.             animationPlayer.SetBool("Walking", false);
    53.             animationPlayer.SetBool("JumpingV", false);
    54.             animationPlayer.SetBool("FallingV", false);
    55.             animationPlayer.SetBool("JumpingH", false);
    56.             animationPlayer.SetBool("FallingH", false);
    57.             if (rb.velocity.x != 0 && move != 0)
    58.             {
    59.                 animationPlayer.SetBool("Walking", true);
    60.             }
    61.             else
    62.             {
    63.                 animationPlayer.SetBool("Walking", false);
    64.             }
    65.        
    66.         }
    67.         else
    68.         {
    69.             if (rb.velocity.x == 0)
    70.            
    71.                 if (rb.velocity.y > 0)
    72.                 animationPlayer.SetBool("JumpingV", true);
    73.                 animationPlayer.SetBool("FallingV", false);
    74.                 animationPlayer.SetBool("JumpingH", false);
    75.                 animationPlayer.SetBool("FallingH", false);
    76.  
    77.             if (rb.velocity.y < 0)
    78.             {
    79.                 animationPlayer.SetBool("JumpingV", false);
    80.                 animationPlayer.SetBool("FallingV", true);
    81.                 animationPlayer.SetBool("JumpingH", false);
    82.                 animationPlayer.SetBool("FallingH", false);
    83.             }
    84.         }
    85.         else
    86.         {
    87.             if (rb.velocity.y > 0)
    88.             {
    89.                 animationPlayer.SetBool("JumpingV", false);
    90.                 animationPlayer.SetBool("FallingV", false);
    91.                 animationPlayer.SetBool("JumpingH", true);
    92.                 animationPlayer.SetBool("FallingH", false);
    93.             }
    94.             if (rb.velocity.y < 0)
    95.             {
    96.                 animationPlayer.SetBool("JumpingV", false);
    97.                 animationPlayer.SetBool("FallingV", false);
    98.                 animationPlayer.SetBool("JumpingH", false);
    99.                 animationPlayer.SetBool("FallingH", true);
    100.     }  }   }
    101.  
    102.  
    103.     void FixedUpdate()
    104.     {
    105.         rb.velocity = new Vector2(move * moveSpeed, rb.velocity.y);
    106.  
    107.         //Pulo personagem
    108.         if (Jumping)
    109.         {
    110.             //rb.addForce(new Vector2(0f, jumpSpeed), ForceMode2D.Impulse);
    111.             rb.velocity = Vector2.up * jumpSpeed;
    112.  
    113.             Jumping = false;
    114.         }
    115.    }  }
    116.  
    117.  
    I Have same problem, on lines - 66 ande 84, please, help me!!
     
  21. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You have two { brackets after Update. And you have 2 sometimes 3 brackets on the same line sometimes, I would advise against that for this very reason, hard to track down. It's easy to fix these types of errors. Delete (copy) everything in the class, and get it working. Then add one method back at time, basic troubleshooting steps.
     
    vletsy likes this.
  22. vletsy

    vletsy

    Joined:
    Oct 13, 2019
    Posts:
    1
    Can Somebody help me i am struggeling for like 4 hours with this problem. My Console gives me 6 error's
    2 with the code: CS1513
    2 with the code: CS1002
    1 with this code: CS1525
    and 1 with this code: CS1026

    But i can't find any problems also visual studio and notepad++ can't find any problems.
    please help me i am an beginner and yeah please help me!

    (edit): And they say weird numbers also like (26,12) is that the line where the mistake is?
    one of the sense: Assets\Joystick.cs(26,12): error CS1525: Invalid expression term ','
     
    Last edited: Oct 13, 2019
  23. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry no, not without seeing your code. But as a beginner, I might suggest following my previous post.
     
  24. lingingicey

    lingingicey

    Joined:
    Oct 5, 2019
    Posts:
    1
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.  
    8.     [HideInInspector]
    9.     public playerDirection direction;
    10.  
    11.     [HideInInspector]
    12.     public float step_Length = 0.2f;
    13.  
    14.     [HideInInspector]
    15.     public float movement_Frequency = 0.1f;
    16.  
    17.     private float counter;
    18.     private bool move;
    19.  
    20.     [SerializeField]
    21.     private GameObject tailPrefab;
    22.  
    23.     private List<Vector3> delta_Position;
    24.  
    25.     private List<Rigidbody> nodes;
    26.  
    27.     private Rigidbody main_Body;
    28.     private Rigidbody head_Body;
    29.     private Transform tr;
    30.  
    31.     private bool create_Node_At_Tail;
    32.  
    33.     void Awake()
    34.     {
    35.         tr = transform;
    36.         main_Body = GetComponent<Rigidbody>();
    37.  
    38.         //InitSnakeNodes();
    39.         //InitPlayer();
    40.  
    41.     }
    42.  
    43.     // Update is called once per frame
    44.     void Update()
    45.     {
    46.  
    47.     }
    48.  
    49.  
    50.  
    51.     void InitSnakeNodes()
    52.     {
    53.         nodes new List<Rigidbody>();
    54.  
    55.         nodes.Add(tr.GetChild(0).GetComponent<Rigidbody>());
    56.         nodes.Add(tr.GetChild(1).GetComponent<Rigidbody>());
    57.         nodes.Add(tr.GetChild(2).GetComponent<Rigidbody>());
    58.     }
    59.  
    60. } // class
    61.  
    How can I fix this I have a CS1002 Error. THanks in advance.
     
  25. KCrystian

    KCrystian

    Joined:
    Oct 29, 2019
    Posts:
    4
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. namespace KartGame.KartSystems
    6. {
    7.     /// <summary>
    8.     /// A basic keyboard implementation of the IInput interface for all the input information a kart needs.
    9.     /// </summary>
    10.     public class KeyboardInput : MonoBehaviour, IInput
    11.     {
    12.         public float Acceleration
    13.         {
    14.             get { return m_Acceleration; }
    15.         }
    16.         public float Steering
    17.         {
    18.             get { return m_Steering; }
    19.         }
    20.         public bool BoostPressed
    21.         {
    22.             get { return m_BoostPressed; }
    23.         }
    24.         public bool FirePressed
    25.         {
    26.             get { return m_FirePressed; }
    27.         }
    28.         public bool HopPressed
    29.         {
    30.             get { return m_HopPressed; }
    31.         }
    32.         public bool HopHeld
    33.         {
    34.             get { return m_HopHeld; }
    35.         }
    36.  
    37.         float m_Acceleration;
    38.         float m_Steering;
    39.         bool m_HopPressed;
    40.         bool m_HopHeld;
    41.         bool m_BoostPressed;
    42.         bool m_FirePressed;
    43.  
    44.         bool m_FixedUpdateHappened;
    45.  
    46.         void Update ()
    47.         {
    48.             if (Input.GetKey (KeyCode.UpArrow))
    49.                 m_Acceleration = 1f;
    50.             else if (Input.GetKey (KeyCode.DownArrow))
    51.                 m_Acceleration = -1f;
    52.             else
    53.                 m_Acceleration = 0f;
    54.  
    55.             if (Input.GetKey (KeyCode.LeftArrow) && !Input.GetKey (KeyCode.RightArrow))
    56.                 m_Steering = -1f;
    57.             else if (!Input.GetKey (KeyCode.LeftArrow) && Input.GetKey (KeyCode.RightArrow))
    58.                 m_Steering = 1f;
    59.             else
    60.                 m_Steering = 0f;
    61.  
    62.             m_HopHeld = Input.GetKey (KeyCode.Space);
    63.  
    64.             if (m_FixedUpdateHappened)
    65.             {
    66.                 m_FixedUpdateHappened = false;
    67.  
    68.                 m_HopPressed = false;
    69.                 m_BoostPressed = false;
    70.                 m_FirePressed = false;
    71.             }
    72.  
    73.             m_HopPressed |= Input.GetKeyDown (KeyCode.Space);
    74.             m_BoostPressed |= Input.GetKeyDown (KeyCode.LeftShift);
    75.             m_FirePressed |= Input.GetKeyDown (KeyCode.LeftControl);
    76.      
    77.  
    78.         void FixedUpdate ()
    79.         {
    80.             m_FixedUpdateHappened = true;}
     
  26. KCrystian

    KCrystian

    Joined:
    Oct 29, 2019
    Posts:
    4
    Hello everyone, I'm having trouble with the code above ^, (80,43): error CS1513: } expected comes up.
     
  27. unity_l0zItqiLRq614A

    unity_l0zItqiLRq614A

    Joined:
    Nov 22, 2019
    Posts:
    1
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Player : MonoBehaviour
    6. {
    7.     public float speed;
    8.     public int jumpForce;
    9.     public int health;
    10.     public Transform groundCheck;
    11.  
    12.     private bool invunarable = false;
    13.     private bool grounded = false;
    14.     private bool jumping = false;
    15.     private bool facingRight = true;
    16.  
    17.     private SpriteRenderer sprite;
    18.     private Rigidbody2D rb2d;
    19.     private Animator anim;
    20.  
    21.  
    22.     // Start is called before the first frame update
    23.     void Start() {
    24.         sprite = GetComponent<SpriteRenderer> ();
    25.         rb2d = GetComponent<Rigidbody2D> ();
    26.         anim = GetComponent<Animator> ();
    27.      
    28.     }
    29.  
    30.     // Update is called once per frame
    31.     void Update() {
    32.  
    33.     }
    34.  
    35.     void FixedUpdate () {
    36.  
    37.  
    38.         float move = Input.GetAxis("Horizontal");
    39.         rb2d.velocity = new Vector2(move * speed, rb2d.velocity.y);
    40.  
    41.     }
    Where is the error? In Unity appears Assets \ Script \ Player.cs (41,6): errorCS1513:} expected
     
  28. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @unity_l0zItqiLRq614A Yes, a quick inspection shows that you are missing the } at the very end of the file. They always come in two's, so you go through and match them up. The very last one that you currently have matches the opening bracket for FixedUpdate, so you need the closing one for the entire class.
     
  29. lancastergames48

    lancastergames48

    Joined:
    Feb 22, 2019
    Posts:
    3
    please help i have been going over my errors code's and haven't been able to find a solution.
    Assets\MotionController.cs(24,10): error CS1513: } expected
    Assets\MotionController.cs(28,18): error CS1513: } expected
    Assets\MotionController.cs(32,22): error CS1513: } expected

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class MotionController : PlayerMotor
    7. {
    8. public float moveTime;
    9.  
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         PlayerMotor;
    14.         moveTime = travelSpeed*Time.deltaTime;
    15.      
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.        //"w" to move forward
    22.         if (Input.GetKey(KeyCode.W));
    23.         {
    24.         transform.Translate (Vector3.forward*moveTime);
    25.         }
    26.         //"s" to move back
    27.             else(Input.GetKey(KeyCode.S));
    28.                 {
    29.                     transform.Translate((Vector3.back)*moveTime);
    30.                 }
    31.                 //"d" to move right
    32.                 else(Input.GetKey(KeyCode.D));
    33.                     {
    34.                         transform.Translate ((Vector3.right)*moveTime);
    35.                     }
    36.                     //"a" to move left
    37.                     else (Input.GetKey(KeyCode.A));
    38.                         {
    39.                             transform.Translate ((Vector3.left)*moveTime);
    40.                         }
    41.      
    42.     }
    43. }
    i have tried if, switch, else if, else, input.getaxis, i keep getting these same errors on the same lines.
     
  30. Fasticboss

    Fasticboss

    Joined:
    Nov 24, 2019
    Posts:
    2
    Can any on help me im having a problem

    heres my code

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

    public class PlayerControl : MonoBehaviour




    public float moveSpeed;
    // public Rigidbody theRB;
    public float jumpForce;
    public CharacterController controller;

    private Vecter3 moveDirection;


    // Start is called before the first frame update
    void Start() {
    // theRB = GetComponent<Rigidbody>();
    controler = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update() {
    // theRB.velocity = new Vecter3(Input.Getxis("Horizontal") * moveSpeed, theRB.velocity.y, Input.GetAxis("Vertical") * movespeed);

    // if(Input.GetButtonDown("jump"))
    // {
    // theRB.velocity = new Vector3(theRB.velocity.x, jumpForce, theRB.velocity.z);
    // }

    moveDirection = new Vecter3(Input.Getxis("Horizontal") * moveSpeed, 0f, Input.GetAxis("Vertical") * movespeed);

    if(Input.GetButtonDown("jump")) {
    moveDirection.y = jumpForce;
    }
    controller.Move(moveDirection);
    }
    "

    heres my error messages

    "
    Assets\PlayerController.cs(5,43): error CS1514: { expected
    "
    Assets\PlayerController.cs(5,43): error CS1513: } expected
    "
     
  31. lancastergames48

    lancastergames48

    Joined:
    Feb 22, 2019
    Posts:
    3
    Please "insertCode" but it looks like a set of missing brackets but its a little jumbled without the line annotations.
     
  32. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Simply remove all the methods until you have just the class definition. Then add your methods back in, one at a time. Basic troubleshooting for any issue. When the error shows the line number (5,43 means line 5), please tell US the line that it is pointing to so we don't have to guess.
     
    pimgames likes this.
  33. pwm_123

    pwm_123

    Joined:
    Jan 25, 2020
    Posts:
    1
    i have the same problem and no matter what i try the error wont go away someone plz help
     

    Attached Files:

  34. pimgames

    pimgames

    Joined:
    Jan 4, 2020
    Posts:
    1
    alguem me ajuda!
    codigo:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [RequireComponent(typeof(Rigidbody))]
    6. public class PlayerMotor : MonoBehaviour {
    7.  
    8.    [Header("System")]
    9.    public Camera cam;
    10.  
    11.    //Privates
    12.    private Vector3 velocity = Vector3.zero;
    13.    private Vector3 rotation = Vector3.zero;
    14.    private Vector3 cameraRotation = Vector3.zero;
    15.    private Rigidbody rb;
    16.  
    17.     void Start() {
    18.         rb = GetComponent<Rigidbody> ();
    19.     }
    20.  
    21.     public void Move(Vector3 _velocity)
    22.     {
    23.         velocity = _velocity;
    24.     }
    25.  
    26.     public void Rotate(Vector3 _rotation){
    27.         rotation = _rotation;
    28.     }
    29.  
    30.     public void RotationCamera(Vector3 _cameraRotation){
    31.         cameraRotation = _cameraRotation;
    32.     }
    33.  
    34.     void FixedUpdate(){
    35.         PlayRotation ();
    36.         PlayMoviment ();
    37.     }
    38.  
    39.     void PlayRotation(){
    40.          rb.MoveRotation (rb.rotation * Quartenion.Euler (rotation));
    41.          if (cam != null) {
    42.              cam.transform.Rotate (-cameraRotation);
    43.          }
    44.     }
    45.  
    46.     void PlayMoviment(){
    47.         if (velocity != Vector3.zero) {
    48.         rb.MovePosition (rb.position + velocity * Time.fixedDeltaTime);
    49.     }
    50. }
    51.  
    52.  
    53. erro:
    54. PlayerMotor.cs(50,2): error CS1513: } expected
     
  35. ToffeeRecord

    ToffeeRecord

    Joined:
    Mar 18, 2020
    Posts:
    7
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.AI;
    6.  
    7. public class BeansScript : MonoBehaviour
    8. {
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         this.agent = base.GetComponent<NavMeshAgent>(); // Define the AI Agent
    13.         this.Wander(); //Start wandering
    14.         this.waitTime = UnityEngine.Random.Range(5f, 10f);
    15.         this.waitGumTime = UnityEngine.Random.Range(5f, 10f);
    16.     }
    17.  
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         if(this.waitTime > 0f)
    22.         {
    23.             this.waitTime -= Time.deltaTime;
    24.         }
    25.         if(this.waitGumTime > 0f & this.waitTime <= 0f)
    26.         {
    27.             this.ChewGum();
    28.         }
    29.         else
    30.         {
    31.             this.StopChewingGum();
    32.         }
    33.     }
    34.    
    35.     // FixedUpdate is called after waitTime went below 0f
    36.     void FixedUpdate()
    37.     {
    38.     Vector3 direction = this.player.position - base.transform.position;
    39.     RaycastHit raycastHit;
    40.     if (Physics.Raycast(base.transform.position, direction, out raycastHit, float.PositiveInfinity, 3, QueryTriggerInteraction.Ignore) & raycastHit.transform.tag == "Player") //Check if its the player
    41.     {
    42.         this.db = true;
    43.         this.TargetPlayer(); //Head towards the player
    44.     }
    45.     else
    46.     {
    47.         this.db = false;
    48.         if (this.agent.velocity.magnitude <= 1f & this.coolDown <= 0f)
    49.         {
    50.             this.Wander(); //Just wander
    51.         }
    52.     }
    53.    
    54.     // ChewGum is called when Beans will chew his gum
    55.     void ChewGum()
    56.     {
    57.         this.agent.speed = 0f;
    58.         this.beanAnimator.SetBool("EatingGum", true);
    59.         if(this.waitGumTime > 0f)
    60.         {
    61.             this.waitGumTime -= Time.deltaTime;
    62.         }
    63.     }
    64.    
    65.     //StopChewingGum is called when Beans wants to stop chewing gum
    66.     void StopChewingGum()
    67.     {
    68.         if(this.waitGumTime <= 0f)
    69.         {
    70.             this.agent.speed = 7f;
    71.             this.beanAnimator.SetBool("EatingGum", false);
    72.             this.waitTime = UnityEngine.Random.Range(5f, 10f);
    73.         }
    74.     this.waitGumTime = UnityEngine.Random.Range(5f, 10f);
    75.     }
    76.    
    77.     // Token: 0x060000B1 RID: 177 RVA: 0x00006629 File Offset: 0x00004A29
    78.     void Wander()
    79.     {
    80.         this.wanderer.GetNewTarget(); //Get a new target on the map
    81.         this.agent.SetDestination(this.wanderTarget.position); //Set its destination to position of the wanderTarget
    82.         this.coolDown = 1f;
    83.     }
    84.    
    85.     // Token: 0x060000B2 RID: 178 RVA: 0x00006658 File Offset: 0x00004A58
    86.     void TargetPlayer()
    87.     {
    88.         this.agent.SetDestination(this.player.position); //Set it's destination to the player
    89.         this.coolDown = 1f;
    90.     }
    91.    
    92.     // Token: 0x04000125 RID: 282
    93.     public bool db;
    94.  
    95.     // Token: 0x04000126 RID: 283
    96.     public Transform player;
    97.  
    98.     // Token: 0x04000127 RID: 284
    99.     public Transform wanderTarget;
    100.  
    101.     // Token: 0x04000128 RID: 285
    102.     public AILocationSelectorScript wanderer;
    103.  
    104.     // Token: 0x04000129 RID: 286
    105.     public float coolDown;
    106.    
    107.     // Token: 0x04000129 RID: 287
    108.     public float waitTime;
    109.    
    110.     // Token: 0x0400012A RID: 298
    111.     private NavMeshAgent agent;
    112.    
    113.     // Token: 0x0400012B RID: 289
    114.     public float waitGumTime;
    115.    
    116.     // Token: 0x0400012C RID: 290
    117.     public Animator beanAnimator;
    118. }
    119.  
    Apparently it says "(90,3) Error CS1513: } expected", i checked it, IT HAS THAT } in there
     
    NAcademyKid10 likes this.
  36. Tyrceratops

    Tyrceratops

    Joined:
    Mar 30, 2020
    Posts:
    2
    [ERROR:] Assets\PlayerController.cs(51,7): error CS1513: } expected
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour {
    6.  
    7.     bool canJump;
    8.  
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.    
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         if (Input.GetKey("left"))
    19.         {
    20.             gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(-1000f * Time.deltaTime, 0));
    21.         }
    22.  
    23.         if (Input.GetKey("right"))
    24.         {
    25.             gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(1000f * Time.deltaTime, 0));
    26.         }
    27.  
    28.         ManageJump();
    29.  
    30.     }
    31.  
    32.         void ManageJump()
    33.         {
    34.             if(gameObject.transform.position.y <= 0)
    35.             {
    36.                  canJump = true;
    37.             }
    38.  
    39.             if(Input.GetKey("up") && canJump && gameObject.transform.position.y < 10)
    40.             {
    41.                 gameObject.transform.Translate(0, 50f * Time.deltaTime, 0);
    42.             }
    43.             else
    44.             {
    45.                 canJump = false;
    46.  
    47.                 if (gameObject.transform.position.y > 0)
    48.                 {
    49.                     gameObject.transform.Translate(0, -50f * Time.deltaTime, 0);
    50.                 }
    51.             }
    52.         }
    53.  
    54.  
    55.  
    Help?
     
  37. TheBestDraio

    TheBestDraio

    Joined:
    May 16, 2020
    Posts:
    2
    i have problem i want to make a fps controller i write codes. but i see error-cs1513-expected.
    Code :

    using System.Collections;
    using UnityEngine;

    public class Controller

    {
    public Rigidbody rb;


    // axis input vars
    public float walkSpeed = 5.0f;
    public float walkAcceleration = 0.1f;

    float forwardSpeed = 0.0f;
    float backSpeed = 0.0f;
    float rightSpeed = 0.0f;
    float leftSpeed = 0.0f;


    // sprint vars
    public float sprintSpeed = 10.0f;


    // mouse input vars
    public float mouseSensitivity = 5.0f;
    public float upDownRange = 80.0f;

    float verticalRotation = 0;


    // use this for initialization
    void Start()
    {

    Screen.lockCursor = true;

    rb = GetComponent<Rigidbody>();
    }

    void Update()
    {

    if (Input.GetKeyDown("escape"))
    Screen.lockCursor = false;


    // sprint
    if (Input.GetButtonDown("Sprint"))
    {

    forwardSpeed = sprintSpeed;
    }

    if (Input.GetButtonUp("Sprint"))
    {

    forwardSpeed = walkSpeed;
    }
    }

    void FixedUpdate()
    {


    // mouse inputs
    float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
    transform.Rotate(0, rotLeftRight, 0);

    verticalRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
    verticalRotation = Mathf.Clamp(verticalRotation, -upDownRange, upDownRange);
    Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
    }
     
  38. TheBestDraio

    TheBestDraio

    Joined:
    May 16, 2020
    Posts:
    2
    if i try to make rigidbody fps controller i see the cs1513 expected problem.

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3.  
    4. public class Controller
    5.  
    6. {
    7.     public Rigidbody rb;
    8.  
    9.  
    10.     // axis input vars
    11.     public float walkSpeed = 5.0f;
    12.     public float walkAcceleration = 0.1f;
    13.  
    14.     float forwardSpeed = 0.0f;
    15.     float backSpeed = 0.0f;
    16.     float rightSpeed = 0.0f;
    17.     float leftSpeed = 0.0f;
    18.  
    19.  
    20.     // sprint vars
    21.     public float sprintSpeed = 10.0f;
    22.  
    23.  
    24.     // mouse input vars
    25.     public float mouseSensitivity = 5.0f;
    26.     public float upDownRange = 80.0f;
    27.  
    28.     float verticalRotation = 0;
    29.  
    30.  
    31.     // use this for initialization
    32.     void Start()
    33.     {
    34.  
    35.         Screen.lockCursor = true;
    36.  
    37.         rb = GetComponent<Rigidbody>();
    38.     }
    39.  
    40.     void Update()
    41.     {
    42.  
    43.         if (Input.GetKeyDown("escape"))
    44.             Screen.lockCursor = false;
    45.  
    46.  
    47.         // sprint
    48.         if (Input.GetButtonDown("Sprint"))
    49.         {
    50.  
    51.             forwardSpeed = sprintSpeed;
    52.         }
    53.  
    54.         if (Input.GetButtonUp("Sprint"))
    55.         {
    56.  
    57.             forwardSpeed = walkSpeed;
    58.         }
    59.     }
    60.  
    61.     void FixedUpdate()
    62.     {
    63.  
    64.  
    65.         // mouse inputs
    66.         float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
    67.         transform.Rotate(0, rotLeftRight, 0);
    68.  
    69.         verticalRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
    70.         verticalRotation = Mathf.Clamp(verticalRotation, -upDownRange, upDownRange);
    71.         Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
    72.     }
    73.  
     
  39. trimmmwas

    trimmmwas

    Joined:
    May 28, 2020
    Posts:
    1
    someone please help me I am having trouble with this code

    Here is it:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class LevelName : MonoBehaviour {
    6.  
    7.       public Text levelName;
    8.  
    9.     void Start() {
    10.     {
    11.         levelName.text = (SceneManager.GetActiveScene().name);
    12.     }
    13. }
    when I space it, it says expected but 1 column after, I do that again and again and it is still like that. WHAT I DO?
     
Thread Status:
Not open for further replies.