2D gun shooting and fliping

Hi guys i am trying to retro the game as a execercise. I am facing a problem about the movement of the gun.

So this is the game play video.

How do i play with the function AddForce or AddTorque in order to make my gun flip based on the angle of the gun?

Thank you so much!

You might be interested in AddForceAtPosition. You could add a force at the tip of the gun.