How can I rotate an object to be perpendicular to a surface it hits (in 2D);

I’m making a mobile game, and I want to make the player rotate to be perpendicular to the object that it hits.

Assuming you know the rotation of the surface that has been hit you set the player rotation to the same like the surface that has been hit and add 90 degree to the z axis rotation of the player.