Forcing Shift-Lock help

Hi everyone!

I’m struggling to bypass a system that is essentially implemented for next to no reason. There is currently no way to actually force a shift lock when it was disabled. However, there are games that do show it’s possible to toggle it on and off. And now I’m attempting to figure that out on my own.

I wasn’t able to figure it out, but I was close. Here are my findings(to anyone who knows the camera well these may be fairly basic, but they were what I was able to understand with about an hours worth of reverse engineering)

  • The camera is essentially a position that keeps moving itself
  • The camera uses a table to get information and then proceeds to use that to shift the camera position
  • The Shiftlockcontroller uses multiple different functions to verify that a user is indeed shift locked.

Those were just a couple of things I found. I could go into more detail if asked. The main issue I have at the moment is finding where the controller is being called from. Because if I can figure that out I’ll be able to call it from any script theoretically.

OR

I may just be over thinking basically everything and there may be a quick fix I don’t know about. I searched all the links I could find and found nothing. Does anyone have any ideas? Thanks!

2 Likes

I was able to force a shift lock when guns were equipped in a game I started with a friend a few weeks ago. It isn’t a perfect solution, and it locks our game out of getting automatic StarterPlayer updates, but it does its job well enough in the context of our game.

ShiftLockController: https://pastebin.com/hAf1MDWY
RootCamera: https://pastebin.com/M1UqkZ02 (i think the important line is 1391)

I would go into more detail about what exactly I did, but I would need to study the code modifications to see how it works again and I need to get to bed. I can take a closer look at it again tomorrow to see if I can help you more directly, but for now I hope the code helps you enough.

2 Likes

It appears that all of the behavior updates come from specifically the function this:UpdateMouseBehavior() defined on line 428. It hooks into the ShiftLockController using an event on line 1388 when the custom camera object’s ConnectInputEvents method is called, which appears to be an initialization type function.

The logic for choosing when to set when the shift lock is enabled is entirely inside of ShiftLockController, but the camera locking behavior is inside of UpdateMouseBehavior where it changes UserInputService.MouseBehavior. Lines 125 and 135 have the functions onShiftInputBegan and onShiftInputEnded which handle UserInputService events, listening for left shift key presses to toggle shift lock. Line 215 listens for LocalPlayer.Changed and handles shift lock mode changes based on what settings the developer set. Line 198 listens for GameSettings.Changed to check when a user’s settings change. GameSettings is also used on line 44 (commented out in my modification) in isShiftLockMode to prevent players from using it when they have it disabled. When the mode changes it fires the ShiftLockController.OnShiftLockToggled event to communicate with RootCamera.

I made some major modifications to it to force it when I wanted it to happen in ShiftLockController, like the comment on line 44, the new event connection on line 175, and the comment on line 199. My version isn’t a perfect 1:1 comparison to the stock CameraScript since it has been heavily modified to work with my game’s gun system, but the main control flow is still there and you should be able to find these functions inside of the stock version.

Since you want to force a shift lock then you should probably look into the LocalPlayer.Changed event, and the isShiftLockMode function to change the conditions of when a shift lock is set. You should also look into initialize where the shift lock GUI is connected to shift lock toggling, the mouseLockSwitchFunc where it is toggled, onShiftInputEnded where mouseLockSwitchFunc is called, and the two functions enableShiftLock and disableShiftLock which force the shift lock mode into a specific state. GameSettings.Changed and LocalPlayer.Changed both use the previous two functions to manipulate when shift lock is set.

It doesn’t appear like there is a built in way to allow the developer to force shift lock mode, but luckily we can add our own with the above knowledge.

I hope this dissection of the code helps you solve the problem!

I’ll look into it. Thanks a million!