On collision x or y 2d c#

I am making a game kind of like Mario, and I am making the enemy. The enemy should be killed if the player collides with the enemy on the y axis, but the player should lose health if the player collides with the enemy on the x axis. Is there a way to do this, while still in the OnCollisionEnter2D? Thanks!

Take a look at this How can I detect which SIDE of a box I collided with? - Unity Answers should be easy to figure out which part of the collider the player is colliding with.