Camera I Like

I like the free look but i would change that fact the you would have to press the right button to rotation the camera. As a oppose to the moving the mouse.

I changed the Update() to this. It works for me.

protected void Update()
        {
            if ( Input.GetMouseButton( 1 ) ) // When the RightMouseButton is held.
            {
                Cursor.lockState = CursorLockMode.Locked;  // Place the cursor in center of screen, stop its movement, and make it disappear. 
                HandleRotationMovement();

                // I have no Idea what this does
                if ( m_LockCursor && Input.GetMouseButtonUp( 0 ) )
                {
                    Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None;
                    Cursor.visible = !m_LockCursor;
                } //End of no Idea
            }
            else
            {
                Cursor.lockState = CursorLockMode.None; // Make cursor reappear and move again.
                return;
            }
        }

I have no idea what

if ( m_LockCursor && Input.GetMouseButtonUp( 0 ) )
                {
                    Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None;
                    Cursor.visible = !m_LockCursor;
                }

does, so I left it there.

question: does this line keep the mouse cursor in “that” position when button is clicked (i.e stops the cursor from moving?), while allowing user to rotate camera?

Locking the cursor it moves to the center of the screen (unseen) so when you release the right mouse button, the cursor is front and center, not in some random place on the screen. The cursor will not be where it was when you right-clicked.

That said, you will have the full camera movement that FreeLookCam.cs has, just with out seeing the cursor.

A quick right-click will recenter your cursor with this code.

Privacy & Terms