老师 就是第一人称射击游戏 让枪跟随视野(鼠标)移动 我试着改unity第一人称资源包里面的mouselook 但是没改对 就是下面注释的两行 并没有什么变化 查阅了一些资料 对旋转 还是有点懵 麻烦指点下
public void LookRotation(Transform character, Transform camera)
{
float yRot = CrossPlatformInputManager.GetAxis("Mouse X") * XSensitivity;
float xRot = CrossPlatformInputManager.GetAxis("Mouse Y") * YSensitivity;
m_CharacterTargetRot *= Quaternion.Euler (0f, yRot, 0f);
m_CameraTargetRot *= Quaternion.Euler (-xRot, 0f, 0f);
//eulerAnglers = solider.transform.localEulerAngles;
if (clampVerticalRotation)
m_CameraTargetRot = ClampRotationAroundXAxis (m_CameraTargetRot);
if (smooth)
{
character.localRotation = Quaternion.Slerp (character.localRotation, m_CharacterTargetRot,
smoothTime * Time.deltaTime);
camera.localRotation = Quaternion.Slerp (camera.localRotation, m_CameraTargetRot,
smoothTime * Time.deltaTime);
//solider.localEulerAngles = new Vector3(eulerAnglers.x, eulerAnglers.y,solider.localEulerAngles.z+yRot );
}
else
{
character.localRotation = m_CharacterTargetRot;
camera.localRotation = m_CameraTargetRot;
}
UpdateCursorLock();
}