How would I create a "Fake Shiftlock"

I would like to have the camera be locked to the cursor, but have the movement of the character as if I was not in shiftlock.

I tried to rotate the character whilst moving in shiftlock, which ended up stuttering between facing foward relative to the camera to facing the moving direction relative to the camera.

I was looking for something a little more static, simplistic, and mainly something that actually works.

This is what I tried, with no changes to the camera type.

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	local moveDirection = humanoid.MoveDirection
	
	local rotation = math.atan2(moveDirection.X, 0, moveDirection.Z)
	print(math.deg(rotation))
	
	character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.deg(rotation), 0)
end)

So you want shiftlock, but without the character’s rotation being locked to the camera?

What you can do to achieve that is disable Humanoid.AutoRotate property and manually interpolate HumanoidRootPart’s rotation every frame

Here’s a script for that
it should be a local script and it should be put into StarterCharacterScripts which is inside StarterPlayer

you can configure how fast the character rotates by changing the InterpolationSpeed variable

local InterpolationSpeed = 8

-- Settings

local RunService = game:GetService("RunService")

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")

Humanoid.AutoRotate = false

RunService.RenderStepped:Connect(function(DeltaTime)
	local MoveDirection = Humanoid.MoveDirection * Vector3.new(1, 0, 1)
	if MoveDirection.Magnitude > 0 then
		local TargetRotation = CFrame.lookAt(Vector3.zero, MoveDirection)
		local t = 1 - math.exp(-DeltaTime * InterpolationSpeed)
		
		RootPart.CFrame = RootPart.CFrame.Rotation:Lerp(TargetRotation, t) + RootPart.Position
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.