Mouse Lock (Shift Lock) for Mobile/Touch Devices

You can also check this out on my website, ozzypig.com →

Want to enable mouse lock (shift lock) for your mobile players? You’ve come to the right place!

This pack contains an override for the PlayerModuleLoader which does some fancy-pants fiddling to allow access to both the CameraModule and MouseLockController objects available in the default PlayerModule. No forking or modifying the PlayerModule is necessary!

You also get a topbar button interface that toggles the lock mode, only appearing for TouchEnabled devices. Check out the video above! ↑

Oh, there’s also an INSTRUCTIONS ModuleScript. Read it for the nitty-gritty.

This was made possible using @EgoMoose’s very clever CameraModule API Public Override, which circumvents the UserRemoveTheCameraApi FFlag. I simply put together the MouseLockController bit, a nice UI to go with it, and some instructions.

Get the Model on Roblox website ↓

https://www.roblox.com/library/7333069926

Download the Model from the DevForum ↓

Mobile Mouse Lock.rbxm (12.9 KB)

Some fine print to consider

  • You’ll probably want to tweak this to fit your game, in particular the included interface.
  • This will probably work for a while, though changes Roblox makes to the camera and mouse-lock parts of the PlayerModule may break or cause issues. Speaking of which…
  • I’m not liable if you break your game with this - no warranties included :–)
  • Perhaps in the future Roblox will have formal support for mouse/shift lock for touch - it’s up to you to know whether or not that has happened yet. Search #updates:announcements just in case.
  • I’m also probably not going to provide support or updates for this. But, you’ve got a wonderfully talented community at your fingertips that can help you solve your problems.
36 Likes

As of writing this post, the controller is broken. I looked into it and I am unsure of how the old CameraModule worked but the current one loaded by ROBLOX returns an empty array, indicated here:

local cameraModuleObject = CameraModule.new()

return {}

To fix this, I had to fork the modules and return the singleton class held within cameraModuleObject to get this working again, which is of course not ideal since the whole premise of this is to NOT fork modules but it is a bandaid fix for now until I can look into it a little better.

Apologies for necrobumping but I thought it was important if other developers used this resource and were unsure as to why it stopped working randomly (lots of unhappy players on my end :cry:)

4 Likes

RIP :coffin:

Gonna go out on a limb here and say they probably made that change in response to this or the dependent module. Maybe one day they’ll provide an actual camera API!

3 Likes

Hi, is there any way to use this with a forked PlayerModule? because I kept attempting to make it work with my forked PlayerModule but I failed so I gave up.

1 Like

With a forked (and therefore editable) PlayerModule, you would be able to bypass the need for the original workaround altogether, accessing the camera API directly. So it’ll still work for you just gotta set it up without the workaround.