- Home /
How to stop mouse getting out of the game, my game is in webplayer?
Hello. How can I stop the mouse getting out of my game in webplayer. I have a FPS but my mouse is always getting out of the screen. how can make it that the mouse can't get out of the screen? scripts or tutorials can help me! please help thanks
Answer by asafsitner · Sep 26, 2011 at 08:39 PM
If they go out of focus the mouse won't reset back to it's lock state, so you'll want to include a check to see if the user has clicked somewhere in your game and use Screen.lockCursor = true;
again. Something like
if(Input.GetMouseButtonDown(0))
Screen.lockCursor = true;
You might also want to disable this when bringing up the menu or other GUI, so just make sure you set Screen.lockCursor = false;
when that happens.
Thanks for your post asafsitner. But this is not that what I am searching for... with this script mouse also always get out of the screen... $$anonymous$$aybe, do you or anyone else have a script if mouse get out of gamescreen that the mouse automaticly comes back into the middle of the screen or is it possible to make that the mouse always stay in middle of screen ?
Answer by worldofcars · Sep 27, 2011 at 12:15 PM
Thanks for your post asafsitner. But this is not that what I am searching for... with this script mouse also always get out of the screen... Maybe, do you or anyone else have a script if mouse get out of gamescreen that the mouse automaticly comes back into the middle of the screen or is it possible to make that the mouse always stay in middle of screen ?
Your answer
Follow this Question
Related Questions
Unity 3D Screen.lockCursor Problems 2 Answers
Detect cursor on edge of screen 1 Answer
Problem with mouse cursor disappearing in webplayer 0 Answers
How to detect in which half of the screen the cursor is, no matter the resolution? 1 Answer
How to make something happen when mouse on side of screen? 1 Answer