BCE0044: expecting }, found ''.

#pragma strict

var forward : KeyCode;
var left : KeyCode;
var right : KeyCode;

var thrust : float = 10;
var shipType : Rigidbody2D;

function Start () {
    shipType = GetComponent.<Rigidbody2D>();
}

function Update () {
{
    if (Input.GetKey(forward))
    {
    shipType.AddForce(transform.up * thrust);
    }
}

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!

function Update () {
{    <-----------------------------------------  Sneaky bracket spotted!
    if (Input.GetKey(forward))
    {
    shipType.AddForce(transform.up * thrust);
    }
}
1 Like

one of those examples from that people should learn to put brackets on new line :slight_smile: