- Home /
Disabling a portion of the RigidbodyFPController script in Unity 5
Hey!
I'm trying to make a FPS game, but I am having issues with activating and de-activating my mouse when I open my inventory window. I have gotten the pause menu and mouse to work by freezing the timescale and returning it to normal when resume is called. But I cannot freeze a "multiplayer" game just to bring up the mouse for the inventory tab >,<
So, I went through the RigidbodyFPController script and found the culprit that is making my life difficult.
public void RotateView()
{
//avoids the mouse looking if the game is effectively paused
if (Mathf.Abs(Time.timeScale) < float.Epsilon) return;
// get the rotation before it's changed
float oldYRotation = transform.eulerAngles.y;
mouseLook.LookRotation (transform, cam.transform);
if (m_IsGrounded || advancedSettings.airControl)
{
// Rotate the rigidbody velocity to match the new direction that the character is looking
Quaternion velRotation = Quaternion.AngleAxis(transform.eulerAngles.y - oldYRotation, Vector3.up);
m_RigidBody.velocity = velRotation*m_RigidBody.velocity;
}
}
Now down at mouseLook.Lookrotation is where the issue is. The camera transform locks the mouse to the camera. And I've been trying to turn my head around this by trying to call the RotateView() and disabling it, but it's a nasty bugger and telling me that it's a method, and I will not be disabled.
I found fix, but it's a BAD fix. I can just disable the entire RigibodyFPController script, but that's a very cheap and bad way of doing it ( I think )
Any pointers? I have been coding for 3 weeks, so be gentle and thorough when explaining a fix ^_^