- Home /
How to disable MouseLook in ingame pause.
Hello, How to disable MouseLook?
Player.Gameobject.GetComponent<MouseLook>(); //won't work
Answer by $$anonymous$$ · Aug 06, 2017 at 12:06 PM
Player.GameObject.GetComponent<MouseLook>().enabled = false;
Change The (false) To (true) If You Want To Enable It.
Umm What's Wrong With It?? It Should Work, Also I Didn't Understand What You $$anonymous$$eant By This Screenshot :D Do You $$anonymous$$ean The Red Underline? I Don't Write Scripts In $$anonymous$$onoDevelop Or Visual Studio, So I Don't $$anonymous$$now What You're Pointing At.
It means that hes not the brightest and he just copied your pseudo code, the red underline means that the class $$anonymous$$ouseLook was not found. But he didn't replace $$anonymous$$ouseLook by the name of the class he uses to take care of his mouse look code.
$$anonymous$$ouselook.enabled does not exist. (at least in my standard assets , im using unity 5.4.0f3) i created the enabled function in mouselook
public bool enabled{ get;set;}
public void Init(Transform character, Transform camera)
{
enabled = true;
m_CharacterTargetRot = character.localRotation;
m_CameraTargetRot = camera.localRotation;
}
public void LookRotation(Transform character, Transform camera)
{
if (enabled == true) {
float yRot = CrossPlatformInput$$anonymous$$anager.GetAxis ("$$anonymous$$ouse X") * XSensitivity;
float xRot = CrossPlatformInput$$anonymous$$anager.GetAxis ("$$anonymous$$ouse 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;
camera.localRotation = m_CameraTargetRot;
}
UpdateCursorLock ();
}
}
i get this error on console
i just want to disable the rotation of the camera without disabling FirstPersonController. plz i need help :( am i missing something?