How do I prevent a rigidbody2D from falling through the ground?

I have the following script:

public float speed = 1;
public float jumpForce = 1;

private Rigidbody2D playerBody;
private float trueSpeed;
private float trueJumpForce;

void Start()
{
    playerBody = GetComponent<Rigidbody2D>();

}

void Update()
{
    if (Input.GetKeyDown("d"))
    {
        trueSpeed = speed * Time.deltaTime;
    }
    else if (Input.GetKeyDown("a"))
    {
        trueSpeed = speed * -1 * Time.deltaTime;
    }
    else if (Input.GetKeyDown("w"))
    {
        trueJumpForce = jumpForce * Time.deltaTime;
    }
    else
    {
        trueSpeed = 0.0f;
        trueJumpForce = 0.0f;
    }

    playerBody.AddForce(new Vector2(trueSpeed, trueJumpForce), ForceMode2D.Impulse);
}

but if I run it, the player will fall through everything. I have a ground element which it should land on, but how do I do that?

@myC4 (i’m new to unity as well so don’t take my word for correct)

anyway i recommend adding a boxcollider2d to your ground element (if it’s a box, if it isn’t then add whatever collider shape fits it) and then add a box collider2d to your player so they can collide with things as well. this should keep the player from falling through the ground.,what shape is the ground element? if it’s a basic shape i would add a [shape]collider2d component to it and then add a boxcollider2d component to the player.