Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to keep mouse cursor in the screen ?

Discussion in 'Scripting' started by Erguntech, Apr 24, 2011.

  1. Erguntech

    Erguntech

    Joined:
    Feb 21, 2011
    Posts:
    11
    Hi guys,
    I builded a little sample game with first person shooter script. everything works well with it, and its windowed screen.

    I start the game and when the mouse goes of the screen the character turns too much.

    I want that the mouse cursor cannot go out of the screen. What is the way to do that ?

    Any help would be apreciatted... :rolleyes:
     
  2. BlackGecko

    BlackGecko

    Joined:
    Mar 25, 2011
    Posts:
    10
    I tried hiding the cursor but it didn't work. The cursor can still go out of the window. Maybe the screen object can be helpful
     
  3. Tavahka

    Tavahka

    Joined:
    May 10, 2011
    Posts:
    7
  4. GargerathSunman

    GargerathSunman

    Joined:
    May 1, 2008
    Posts:
    1,571
    Screen.lockCursor may be your only option in this case.