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
Use `Screen.lockCursor = true;`
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… 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 ?