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

How to keep mouse cursor still while rotating a third person camera?

Discussion in 'Scripting' started by RayDawg, Apr 13, 2015.

  1. RayDawg

    RayDawg

    Joined:
    Mar 19, 2013
    Posts:
    108
    Currently, I have a third person camera setup where holding down the right mouse button will hide the cursor and move the camera. However, the mouse cursor is technically moving as well. I want to be able to keep the mouse cursor still but still be able to move the camera.

    I looked on google and through several old topic posts, but it seems that the devs never implemented such a feature back then. Are there any ways to bypass this limitation without adjusting external files or downloading other files?
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
  3. RayDawg

    RayDawg

    Joined:
    Mar 19, 2013
    Posts:
    108
    From what the API describes, it merely locks the cursor in view so the cursor can't move off screen. I want to be able to hold the right click button, move the mouse to move the camera, and then release said button and still have the mouse cursor in the same exact spot as I left it. Is it possible and if so, how??
     
  4. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    233
    Try lock cursor in a build. I don't think it works in the editor or else you'd have a hard time leaving the scene.
     
  5. RayDawg

    RayDawg

    Joined:
    Mar 19, 2013
    Posts:
    108
    I did try both CursorLockMode.Confined and Locked. They both did not get the functionality I was looking for. I don't want to lock the cursor to the center, I want to lock the cursor at its current position when holding down the right mouse button.

    This kind of functionality I'm talking about can be found on many PC games where moving the camera can be done by holding down right click and moving the camera. Once released, the mouse cursor will not have moved at all. Currently, I can move a camera by holding down right click, but I can't get the mouse cursor to stay in the same spot.