Adding force to a bullet as it hits object?

The bullet is a simple prefab with a collider, rigidbody and mesh. I want to shoot boxes and such in the game and have them be “pushed” in the opposite direction of the bullet’s path. Is there any method to do this?

void OnCollisionEnter(Collision collision)
{
if(collision.tag==“stuff to shoot at”)
collision.rigidbody.AddForce(x,y,z);

}

the boxes should have a rigidbody component as well as a colider;

x,y,z the axis you vant to add force e.g rigidbody.AddForce(0,0,10);
you need to tag the boxes with a new tag or you could get rid of the if statement

you should attach this to the bullet prefab

Make the boxes have rigidbodies and the bullet should push the boxes with some force as it collides with them.