Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to lock mouse to middle of screen

Asked by 10 years ago

I am aware that you can use LockFirstPerson for such things, but what i am wanting to do is lock the mouse to the middle of the screen, while the cameratype is Scriptable. The problem with setting the CameraType to custom and back is that it positions the camera back into a 20 stud distance from the focus of the camera, and setting the focus of the camera does not seem to work.

I am not trying to create a 3rd person camera, rather a completly custom camera.

4 answers

Log in to vote
2
Answered by 10 years ago

This is not a valid answer. I am not trying to create a fake mouse, what i am attempting to do is create a custom camera. Creating a fake mouse in the middle of the screen would not help for this, since im trying to make the rotation for it.

I have a while loop checking how much distance the mouse has passed over, then it turns the camera that amount.

But after the mouse gets to the edge of the screen, it starts messing things up, though it still rotates, it ends up with the mouse far off the screen, making it impossible to click anything.

I cannot post in comments yet, because i do not have 10 reputation.

2
This is not an answer. The answers area is for answers to your question ONLY. You need to use comments to reply to specific answers. User#11893 186 — 10y
3
He is unable to post comments because he has less than 10 reputation. I'm upvoting this because it's the only way he can respond. Merely 2122 — 10y
Ad
Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

What you can do is create a "fake" mouse cursor in the center of the screen, using a simple GUI and making the mouse's Icon an invisible image.

To get this mouse's target, simply use a Raycast from the camera's CFrame directed at its lookVector.

Log in to vote
0
Answered by 6 years ago

game.StarterPlayer.CameraMaxZoomDistance = 0

Log in to vote
-1
Answered by 9 years ago

I understand and this is indeed possible now.We will use the UserInput service in a local script to set the Enum in the center so we do Game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter by playing with its MouseBehavior property we can set the Enum to LockCenter for it to stay in that position hope this helps.Farewell

0
Lego, stop trying to get yourself a reputation, ignorant fool. Diitto 230 — 9y

Answer this question