目前在学习第一人称射击...一个问题百思不得其解...
鼠标上下移动控制模型绕Z轴旋转,但是达不到这个效果,模型一点也没有动。
在MouseLook脚本(MouseLook脚本是监听鼠标移动的)中,关键代码如下:
private Vector3 eulerAngles;
void Start ()
{
// Make the rigid body not change rotation
if (GetComponent<Rigidbody>())
GetComponent<Rigidbody>().freezeRotation = true;
eulerAngles = transform.localEulerAngles;
}
void Update ()
{
......
transform.localEulerAngles = new Vector3(eulerAngles.x , eulerAngles.y, eulerAngles.z + rotationY);
}
其中eulerAngles在初始化时记录了旋转角度的初始值,x, y, z都是0,在( axes == RotationAxes.MouseY ) 中使z方向的旋转角度变化,但一直没有发现变化...
运行之前:

运行之后:不论如何移动鼠标,Rotation三个值都不改变

鼠标上下移动控制模型绕Z轴旋转,但是达不到这个效果,模型一点也没有动。
在MouseLook脚本(MouseLook脚本是监听鼠标移动的)中,关键代码如下:
private Vector3 eulerAngles;
void Start ()
{
// Make the rigid body not change rotation
if (GetComponent<Rigidbody>())
GetComponent<Rigidbody>().freezeRotation = true;
eulerAngles = transform.localEulerAngles;
}
void Update ()
{
......
transform.localEulerAngles = new Vector3(eulerAngles.x , eulerAngles.y, eulerAngles.z + rotationY);
}
其中eulerAngles在初始化时记录了旋转角度的初始值,x, y, z都是0,在( axes == RotationAxes.MouseY ) 中使z方向的旋转角度变化,但一直没有发现变化...
运行之前:

运行之后:不论如何移动鼠标,Rotation三个值都不改变
