Making Shift-lock mode not rotate the character

So I’ve been modifying the default Roblox CameraScript. I’ve made it so it now forces mouse lock to be on and I’ve made it so I can set a custom offset for the mouse lock but what I want to do now is make it so your character still faces the direction they move in even with mouse lock enabled. Right now mouse lock forces the character to face the same direction as the camera but I don’t want that.
If someone could tell me where in Roblox’s code this is so I can change it that would be great.

I’ve noticed that if you disable AutoRotate in your character’s humanoid that it stops doing that, but it also stops rotating altogether. I’ve used the Find All function to try and find where anything references AutoRotate and the only references to the property is in an unused script so I’m really confused how it knows if it should rotate the character or not when in first person/ mouse lock.

Thanks for any help.

11 Likes

I believe you’re looking in the wrong area. If anything, CameraScript has to do with the camera and ControlScript has to do with the movement of your characters, so what you’re looking for is in ControlScript. I haven’t played around with any of these scripts since I’ve had no real reason to.

I was originally going to suggest Humanoid.CameraOffset and UserInputService.MouseBehavior but I don’t think that’d accomplish what you want.

1 Like

You can also just make your own camera system with raycasting, user input service, and basic cframe knowledge

Actually I’ve found that the code forcing the character to face the direction the camera is facing in first person and mouse lock isn’t in either the control script nor the camera script. I disabled both of them and used the command line to cframe the camera around and the character still rotated to face the same direction.

Does anyone what’s doing this or is it just part of Roblox’s humanoid and unavoidable?

I’ve found it. It was hard to find.

In the CameraScript.RootCamera module script there is a function called
this:UpdateMouseBehavior().
Within this function there’s a line of code inside the
if isFirstPerson or self:GetShiftLock() then
check called
pcall(function() GameSettings.RotationType = Enum.RotationType.CameraRelative end)
I changed this line of code to be this instead:
pcall(function() GameSettings.RotationType = Enum.RotationType.MovementRelative end)

This was on line 458 in the RootCamera module script but I am modifying this script so it might be on a different line for you.

23 Likes

Follow up: Here’s a free model of my CameraScript if you want to look through it/ use it.

1 Like

Thank you for this post! it helped me out a ton, but how would I go about toggling it? I’ve looked through the camera script, but I can’t seem to find an answer, Would really appreciate it if you could help, thanks again

1 Like

I mentioned where in the code and how to toggle it here:

You could alternatively create a LocalScript in StarterPlayer.StarterPlayerScripts with the following code in it:

while game:GetService("RunService").RenderStepped:Wait() do
	UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.MovementRelative
end

but it would be very unadvisable as this code would be “fighting” with the default camera controller over which movement mode is to be used.

You could also disable the CameraScript (by creating a LocalScript in StarterPlayer.StarterPlayerScripts and naming it “CameraScript” and setting “Disabled” to true on that script) and then calling

UserSettings():GetService("UserGameSettings").RotationType = Enum.RotationType.MovementRelative

In a LocalScript and you wouldn’t need to call it every frame you could just call it once and be done. This of course would have the side effect of the camera would just sit there and not move to follow your character nor rotate when you right-mouse and of course the shift-lock option won’t do anything anymore so this is only really helpful if you’re looking to rewrite the camera script.

4 Likes

Thank you so much!, I’ve been searching for the past 2 weeks about this, you gave such a detailed response, I’m really thankful

2 Likes