FreeLookCam all the way!

I feel like the FreeLookCam is the way to go for my project. I want to add a “RMB” press to move the camera instead of just mouse movement and i’d like the scroll wheel to zoom in and out. Anyone know how i can modify the existing script to achieve this?

@Cryton_Nex to get rotation on RMB I added an instance variable to FreeLookCam.cs:

private bool m_RightMouseDown = false;

and changed the Update method:

protected void Update()
        {
			if(Input.GetMouseButtonDown(1)){
				m_RightMouseDown = true;
			}
			if(Input.GetMouseButtonUp(1)){
				m_RightMouseDown = false;
        	}
			if(m_RightMouseDown){
				HandleRotationMovement();
			} 
            
            if (m_LockCursor && Input.GetMouseButtonUp(0))
            {
                Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None;
                Cursor.visible = !m_LockCursor;
            }
        }

There are probably more elegant ways to do this but it worked for me. I haven’t implemented dollying the camera on mouse scroll.

2 Likes

Privacy & Terms