3D Camera - Pitch not working?

Hi everybody. I’m new to this board and could use some help :frowning:
I am using LWJGL and tried implementing a 3D Camera using this tutorial: http://www.lloydgoodall.com/tutorials/first-person-camera-control-with-lwjgl/
In the walkForward-Method I want to implement moving on the Y-axis too, because I want to achieve a “freelook” kind of movement. I am using tan to calculate this movement:


position.x -= distance * Math.sin(Math.toRadians(yaw));
position.y += distance * Math.tan(Math.toRadians(pitch));
position.z += distance * Math.cos(Math.toRadians(yaw));

The problem is, that when I look straight up or down, the position gets increased by thousands and I get “teleported” away instantly.
Can anyone help me with that or tell me why this is happening?

Cheers
womb34