Stop character mesh from rotating while flying upwards/downwards

I’m having trouble with the flying movement mode. Whenever I press the keys to increase or decrease the altitude my character model always rotates to face a specific direction while flying. But when i change the altitude while moving in any direction (forward, left, right,etc) there isnt any problem. How can I stop it from rotating on its own while only its altitude is supposed to change?

Hello. Were you able to solve this problem?