For when you are in shift lock or first person and your player (humanoidrootpart) rotates when you pan the camera. I want to find out where this is handled so I can modify it, but I can’t seem to find it in PlayerScripts. I’ve tried searching keywords but to no avail.
You may be looking for the MouseLockController
?
It is located under the PlayerScripts
→ PlayerModule
→ CameraModule
I checked that module, but there seemed to be no code relating to changing the player’s rotation during shift lock.
Hi,
You can find first person and shiftlock controls in the BaseCamera script under the function BaseCamera:UpdateMouseBehavior().
function BaseCamera:UpdateMouseBehavior()
local blockToggleDueToClickToMove = UserGameSettings.ComputerMovementMode == Enum.ComputerMovementMode.ClickToMove
if self.isCameraToggle and blockToggleDueToClickToMove == false then
CameraUI.setCameraModeToastEnabled(true)
CameraInput.enableCameraToggleInput()
CameraToggleStateController(self.inFirstPerson)
else
CameraUI.setCameraModeToastEnabled(false)
CameraInput.disableCameraToggleInput()
-- first time transition to first person mode or mouse-locked third person
if self.inFirstPerson or self.inMouseLockedMode then
CameraUtils.setRotationTypeOverride(Enum.RotationType.CameraRelative)
CameraUtils.setMouseBehaviorOverride(Enum.MouseBehavior.LockCenter)
else
CameraUtils.restoreRotationType()
CameraUtils.restoreMouseBehavior()
end
end
end
CameraUtils.setRotationTypeOverride(Enum.RotationType.CameraRelative) controls the humanoid rotation.
Thanks, however, I have another problem. I am trying to create my own custom shift lock instead of using the native one, and whenever I set RotationType to CameraRelative, the camera lags behind, unlike the native one where it immediately snaps to the camera with no delay. Do you know how to fix this?
What RotationType do is control how the client’s character is rotated respective to the camera. By setting to Camera Relative, your character will always try to face the same direction as the camera look direction. RotationType does not affect the camera in anyway, just the character.
If you are trying to do a transition from third to first person, I am unable to help you with that because it is not a straight forward thing to explain and implement. It requires raycasting for occulsion handling, some vector math and springs to get a smooth transition.
Roblox default camera scripts are very well writting with all the mandatory features for a good camera. You can try to read through some of them for your own implementation or forking. I recommend the following scripts: BaseCamera, ClassicCamera, Poppercam and ZoomController.
I hope this helps.
I am not trying to get a first person transition, i’m just trying to find a way to force shift lock. However, trying to enable shift lock the same way the PlayerScripts does results in a laggy camera. I can send a comparison of what I mean
you can set it with this:
UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.CameraRelative