How am I able to click UI buttons while using the FPScontroller?
I was wondering if there was some way I can click UI buttons without moving the screen? I wanted it to instantiate a object at a public drop point that I have.
Comment
Best Answer
Answer by LiloE · Feb 21, 2017 at 09:32 AM
The MouseLook.cs script is used by FPSController to lock the mouse.
You can modify this function to introduce some sort of key combination to disable the mouse look, like they do with escape:
private void InternalLockUpdate()
{
if(Input.GetKeyUp(KeyCode.Escape))
{
m_cursorIsLocked = false;
}
else if(Input.GetMouseButtonUp(0))
{
m_cursorIsLocked = true;
}
if (m_cursorIsLocked)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
else if (!m_cursorIsLocked)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
You may also need to modify this function in the FPSController:
private void RotateView()
{
m_MouseLook.LookRotation (transform, m_Camera.transform);
}