I have a game on Unity3d and I want to rotate player object via script:
Camera.main.transform.Rotate(0, 10, 0);
I can't rotate player object, so I try to rotate it's child object with camera component. And I can do it only when comment 2 strings in the standart script MouseLook.cs:
[Serializable]
public class MouseLook
{
// Variables ..
private Quaternion m_CharacterTargetRot;
private Quaternion m_CameraTargetRot;
public void Init(Transform character, Transform camera)
{
m_CharacterTargetRot = character.localRotation;
m_CameraTargetRot = camera.localRotation;
}
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);
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);
}
else
{
//character.localRotation = m_CharacterTargetRot; // move y axe
//camera.localRotation = m_CameraTargetRot; // move x axe
}
}
}
But when I comment it, my mouse don't react, when I move it. How can I solve it?
