I am new to Unity2D and I am trying to get my sprite to move based on the direction it is facing. I was able to get the rotation based on pressing A or the D key but when it comes to moving forward based on which direction my sprite is facing I am running into errors

My current code :

```
#pragma strict

var moveForward : KeyCode;
var turnRight : KeyCode;
var turnLeft : KeyCode;
var fire : KeyCode;

var speed : float = 4;
var turnSpeed : float = 2;

function Update () {

// When the user wants to jet pulse forward.
if(Input.GetKey(moveForward)){

    // NEEDS FIXING HERE!!! <<<<<
    rigidbody2D.velocity.x = Mathf.Cos(rigidbody2D.rotation) * speed;
    rigidbody2D.velocity.y = Mathf.Sin(rigidbody2D.rotation) * speed;

}

// When we rotate the sprite.
if(Input.GetKey(turnRight)){

    transform.Rotate(0.0f, 0.0f, -5.0f);

}else if(Input.GetKey(turnLeft)){

    transform.Rotate(0.0f, 0.0f, 5.0f);

}
}

```