我正在使用Seabase Alpha的 XNA 相机类,效果很好,我根本不需要修改它。但是,如果我同时水平扫射和偏航,它会改变我的滚动,我无法弄清楚如何以某种方式“锁定”它,使其永远不会滚动。(类似于第一人称射击游戏,它只能扫射、推力和调整它的俯仰和偏航。)
我调用类的代码如下:
if (gamepadState.ThumbSticks.Right.X != 0)
{
// Look Around
camera.Yaw(-gamepadState.ThumbSticks.Right.X);
}
if (gamepadState.ThumbSticks.Right.Y != 0)
{
// Look Around
camera.Pitch(-gamepadState.ThumbSticks.Right.Y);
}
if (gamepadState.ThumbSticks.Left.X != 0)
{
// Move Around
camera.StrafeHorz(-gamepadState.ThumbSticks.Left.X);
}
if (gamepadState.ThumbSticks.Left.Y != 0)
{
// Move Around
camera.Thrust(gamepadState.ThumbSticks.Left.Y);
}
if (gamepadState.Buttons.LeftShoulder == ButtonState.Pressed)
{
camera.StrafeVert(0.2f);
}
if (gamepadState.Buttons.RightShoulder == ButtonState.Pressed)
{
camera.StrafeVert(-0.2f);
}
我尝试将相机类中的 Up 向量强制为Vector(0, 0, 1)
and Vector(0, 1, 0)
。将 Z 设置为 1 有点帮助,但它仍然能够滚动。