Have a look at my post here:
There’s an example of how to clamp an angle depending on the facing direction.