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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

BCE0044: expecting }, found ''.

Discussion in 'Scripting' started by TooLateTheHero, Apr 12, 2015.

  1. TooLateTheHero

    TooLateTheHero

    Joined:
    Apr 14, 2014
    Posts:
    1
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var forward : KeyCode;
    4. var left : KeyCode;
    5. var right : KeyCode;
    6.  
    7. var thrust : float = 10;
    8. var shipType : Rigidbody2D;
    9.  
    10. function Start () {
    11.     shipType = GetComponent.<Rigidbody2D>();
    12. }
    13.  
    14. function Update () {
    15. {
    16.     if (Input.GetKey(forward))
    17.     {
    18.     shipType.AddForce(transform.up * thrust);
    19.     }
    20. }
    Hi guys, fairly new to Unity and JS so bare with me. I'm a tad confused because I'm being thrown this error yet, I can't seem to see what I've done wrong?
    And also, would that be the correct way to add force to a Sprite through means of a 2D game, as what I've read on previous threads has been slightly unclear.
    Thanks for any help!
     
  2. Fajlworks

    Fajlworks

    Joined:
    Sep 8, 2014
    Posts:
    344
    Code (JavaScript):
    1. function Update () {
    2. {    <-----------------------------------------  Sneaky bracket spotted!
    3.     if (Input.GetKey(forward))
    4.     {
    5.     shipType.AddForce(transform.up * thrust);
    6.     }
    7. }
     
    image28 likes this.
  3. mcapousek

    mcapousek

    Joined:
    Jan 11, 2013
    Posts:
    9
    one of those examples from that people should learn to put brackets on new line :)