playMaker

Author Topic: Lock cursor to window?  (Read 4618 times)

shinodan

  • Full Member
  • ***
  • Posts: 180
    • Shinozone
Lock cursor to window?
« on: January 28, 2013, 06:23:10 PM »
Hey in my latest game i have hide cursor set, the aim always points to the mouse position, its a windowed game so the mouse always comes out of the application, i cant use lock cursor because it holds it completely still, is there anything to make the cursor lock to the window only?

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: Lock cursor to window?
« Reply #1 on: January 30, 2013, 08:20:38 PM »
i havnt had any experience with unity and PC builds, however a lot of games in windows don't lock the mouse to the game windows, a good example is skyrim, instead (what I imagine they do) is to use the mouse movement (rather than position) to control the aim and make it so that when you click the mouse buttons it doesn't take you out of the windowed game and into windows.

this may be a better option as it would never limit you to the size of the screen (once the cursor goes fully to the edge of the window you wouldn't be able to move any more in that direction) and instead could get an infinite turn in your environment (first person shooter example)

unfortunately again I don't know how to make sure that your game window stays in focus when clicking outside of it, but the idea might give you a lead to search on.

shinodan

  • Full Member
  • ***
  • Posts: 180
    • Shinozone
Re: Lock cursor to window?
« Reply #2 on: February 03, 2013, 04:38:51 AM »
Yeah ill look into that thanks!