Thanks to both of you for your solutions.
I've actually tested both of them and choosed the solution of dop2000
kriand Your version of the viewing angle works in my project too. The player looks around smooth between the angles 0 to 180 and 180 to 360. The transition between these two states is not very smooth. The player keeps twitching while changing the viewing angle for wxample from 179 to 181.