Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Script Error (cs 1513: } expected)

Discussion in 'Scripting' started by Girodeli, May 19, 2019.

  1. Girodeli

    Girodeli

    Joined:
    May 19, 2019
    Posts:
    1
    I am trying to make a script for my First person game where it makes the player jump. When I'm in Unity it shows an error stating Assets\Scripts\PlayerJump\.cs(19,2): error cs1513: } expected. I am very confused to what all that means. My script is down below. Thanks for any feedback. (I'm using Visual Studio 2019)

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

    public class PlayerJump : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    if(Input.GetKeyDown (KeyCode.Space)) {
    GetComponent<Rigidbody> ().AddForce (Vector3.up * 2000);
    }
    }
     
  2. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    2,300
  3. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    242
    You are missing 1 } at the end.
    Better to use code tags with your posts...
    Here is your code + the }
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerJump : MonoBehaviour
    6. {
    7.     // Start is called before the first frame update
    8.     void Start()
    9.     {
    10.  
    11.     }
    12.  
    13.     // Update is called once per frame
    14.     void Update()
    15.     {
    16.         if(Input.GetKeyDown (KeyCode.Space))
    17.         {
    18.            GetComponent<Rigidbody> ().AddForce (Vector3.up * 2000);
    19.         }
    20.      }
    21. }