You mean the player's direction facing suddenly flipping around? That's because the game's just tracking the mouse position, but the mouse is still there, so when you reach one end of the screen with the mouse, it teleports to the other end, else it can't keep going
That teleportation is what causes you to suddenly look in a different direction, idk how you could fix it though