I’m working on making a custom build mode camera controller which is generally going well, however I was wondering how I could go about restoring the right click to lock cursor position feature that exists by default?
My camera’s CameraType is Scriptable and I believe this removed the mouse locking ability.
Add a LocalScript into StarterPlayer then write this code inside:
local function FocusControl(Name, State, Object)
if State == Enum.UserInputState.Begin then
Camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = true
ContextActionService:UnbindAction("FocusControl")
end
end
ContextActionService:BindAction("FocusControl", FocusControl, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.MouseButton2, Enum.UserInputType.Focus)
I saw that but it’s not really what I’m looking for. Roblox has this behaviour already when the camera’s CameraType is “Custom”, try right clicking when you’re in third person view to get an idea of what I’m looking for.