Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Better Solution than CursorLockMode for FPS?

Discussion in 'WebGL' started by troy_halsey, Jun 4, 2015.

  1. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    63
    Hi!

    Is there a better solution for webGL content using the FPS controller to prevent the camera rotation from stopping when the mouse hits the edge of the screen? I am using mouse lock mode now as everyone suggests, but I actually want the mouse free to click on UI elements. Ideally it would just be a script that says:

    "When the mouse hits the edge the screen, keep moving the camera in that direction until the mouse is moved in the opposite direction."

    Seems simple enough, but I am still reading my first C# book, and have no idea how to write that code or if it's the right solution. I don't like all the notifications MouseLock mode throws in the browser and again, need the mouse for buttons.

    Thanks for any tips,

    Troy
     
  2. troy_halsey

    troy_halsey

    Joined:
    Oct 21, 2014
    Posts:
    63
    So I did some reading and proudly figured out how to make the Camera only move when the user clicks the right mouse button. This frees up the mouse to interact with GUI buttons. So...super simple solution, but being new to coding - I had a major nerdgasm upon success. Still has the browser notification for hiding the mouse, but that is okay...works pretty well. Thanks Interwebs!