Whenever you right click and move your mouse, it locks at it’s current position, and you can freely rotate the camera around the player’s character. I was wondering how I can disable this feature - I guess in the CameraModule script inside the PlayerModule script?
Yes, you need to disable the part of CameraModule that does that. You can also implement your own solution if you need this feature but in different circumstances with this.
I tried commenting this part of the “BaseCamera” ModuleScript which is a child of the “CameraModule” ModuleScript: (line 510-511)
-- elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
-- self:OnMouse2Down(input, processed)
This removed the feature of rotating the camera around the player, but the cursor is still locked at it’s last position. I’ve tried searching through these ModuleScripts and I can’t find any fix to this.
You have a few options here. There are a few CameraTypes that might support the functionality you are looking for. If not you can create a scriptable camera that follows the player’s root part.
If you decide to override the CameraModule you are going to need to find the connection in which it sets the behavior type of the mouse to LockCurrentPosition. Just search the script and you should find it. Also, make sure that this doesn’t interrupt any connections within the RunService portion of the code.
You could just avoid forking the CameraModule altogether and sink the input of the right mouse button instead. I prefer doing this over forking entire modules for a few small tweaks that can be achieved in other ways. I usually reserve forking for major edits or if alternatives aren’t reasonably available.
CameraModule implements the right mouse behaviour via UserInputService.InputBegan. What we can do is take advantage of ContextActionService’s BindActionAtPriority method to bind a function to an input type with a high priority that’ll run over InputBegan. Said function simply sinks the input if called.
Throw this in a blank LocalScript in StarterPlayerScripts and give it a try - you won’t be able to use your right mouse button to turn your camera.
Ah, right. Given that ContextActionService is acting on the right mouse button, that means that most right mouse button interactions would be invalidated since it runs over UserInputService.
You may have to switch any right mouse input over to ContextActionService or look back into the CameraModule to attempt to remove the right mouse code. I could try doing the latter if I have time.
What you could do is switch the ContextActionPriority of the RightMouseDisable action to low, then use BindActionAtPriority again to bind your other right mouse actions but with a higher priority. For example, RightMouseDisable can have Enum.ContextActionPriority.Low.Value, while another one of your actions uses Enum.ContextActionPriority.Low.Value + 100.
Nice this worked for me, also if you want to reenable the rightmouse camera movement just replace the line
“return Enum.ContextActionResult.Sink”
with
“return Enum.ContextActionResult.Pass”