Rigidbody2D.AddForce not works as expected

I make a function to push the player back when it collide with enemy but when it collide from the side of the enemy nothing happen but when the player jump and collide from the top-down the function works.

These are link of png picture of two case collide from the side and from the top-down. And here is my scripts:

private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Enemy"))
        {
             Vector2 pushDirection = (transform.position - collision.transform.position).normalized;
             rb2D.AddForce(pushDirection * pushForce, ForceMode2D.Impulse);
        }
    }

Hard to know without seeing the rest of your code but you could check the following:

  1. As part of your other code, are you setting the player’s velocity when they are stood on the ground? If so, this will override any forces, so your add force won’t work properly.
  2. Does increasing the force help? There might be too much friction between the character and the ground, so the force doesn’t do much with grounded.