Hello, so Im trying to make a gun, I wanna lock the mouse at a custom position of the screen so when players move their mouse the camera moves too.
https://gyazo.com/1abc511fa98c1d1e4e7b5162731da521
I want the mouse to be locked at the position shown in the last seconds.
You aren’t able to lock the player’s mouse yourself, but what you can do is make it look like you are. You could get an Image label of the cursor and place it in the position where you want it to lock. Make the player’s real cursor invisible and when they move their camera around it will look like their mouse is still in that spot.
You may want to set UserInputService.MouseBehaviour
to Enum.MouseBehaviour.LockCenter
and use UserInputService:GetMouseDelta()
to do what the person above has just said.
But then the gun will point to the real mouse and not to the text label
thats why you point the gun to the textlabel instead of the mouse then??!?
and how do I do that? 30charss
not going to give you a full script but you may want to use a BodyGyro
maybe
Right now im using the second property of CFrame(which sets where the front surface has to face) to pooint to the mouse with mouse.Hit.Position, idk how I would do it with a guilabel.
There is a function in the camera object called ViewportPointToRay that will give you a Ray extending outward from the camera you can use the ray to figure out where the fake cursor is pointing.
One question, would it work if I used this to position the mouse and just when the mouse is positioned lock it with locksurrentposition?
Those properties are readonly which means you cannot set those values with a script so that wouldn’t work
Ok so I used this to lock it to the center, but tthe player cannot move the camera Is there any way of doing it like shiftlock?
There are already many threads on the DevForum about creating a shift lock-like camera system that you could search and reference from the forums. Please do use the search feature.
I dont really know how all this stuff is called so I cannot search for it since I dont know how other people name this thing, I would have ot check post by post to see if thats what I was looking for.
Thanks.
Edit: Did some research in the devforum and I think I found what I needed, sorry for not doing it before.