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)