Making a proper jump command with rigidbody2D?

I have added a blank rigidbody2D component for my player character but it doesn’t show up in my PlayerController script. When I try to implement the following code:

else if (Input.GetKey(KeyCode.Space) && !swing && !pierce)
{
if (_isGrounded)
{
_isGrounded = false;
rigidbody2D.AddForce(new Vector2(0, 250), ForceMode.Impulse);
if (current_direction == “left”)
changeState(STATE_JUMP_LEFT);
else
changeState(STATE_JUMP_RIGHT);
}
}

the program always crashes. Does anyone have any suggestions?

3143784–238638–PlayerController.cs (5.73 KB)

just using rigidbody2D is old. You should link it now.

Rigidbody2D rb;

void Start () {
rb = GetComponent <Rigidbody2D> ();
}

and then use your:
rb.AddForce(new Vector2(0, 250), ForceMode.Impulse);