I'm trying to get my camera to move in the direction of it's rotation. My code is mostly working, but I have one problem and I'm not sure how to fix it. I'm trying to make the camera move in any direction on the horizontal plane and up and down on the vertical plane. No rolling. My problem is, when the camera is facing straight up (or close to it) the camera continue to moves on the horizontal plane instead vertically. I don't know how to make it so as the pitch get's closer to 90/-90, the movement on the horizontal plane becomes less and less. Here is my code so far:

void ITransformable::moveInRotation(float distance) { float x = 0.f; float z = 0.f; float y = 0.f; if(mRotation.x < DEGREES_TO_RADIANS(45.f)) { y = std::sin(mRotation.x) * distance; } else { y = std::cos(mRotation.x) * distance; } if(mRotation.y >= DEGREES_TO_RADIANS(90.f)) { mRotation.y -= DEGREES_TO_RADIANS(90.f); } if(mRotation.y < DEGREES_TO_RADIANS(45.f)) { x = std::sin(mRotation.y) * distance; // Find the adjacent side, which is our distance on the x-axis z = std::cos(mRotation.y) * distance; } else { z = std::sin(mRotation.y) * distance; x = std::cos(mRotation.y) * distance; } translate(x, -y, z); }

**Edited by CirdanValen, 05 January 2013 - 05:01 AM.**