I want to achieve a swaying motion when shift lock is activated such as this one:
What is the issue?
I’m currently unable to achieve the swaying motion when shift lock is activated on my character. I’ve tried different scripts and methods, but I’m still not getting the desired effect.
What solutions have you tried so far?
I have tried to look for solutions on the Roblox Developer form and experiment with different methods, but I’m still unable to get the swaying motion to work.
Here is a sample of the code that I’ve tried:
if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
Humanoid.RootPart.CFrame = Humanoid.RootPart.CFrame:Lerp(CFrame.new(Humanoid.RootPart.Position,Vector3.new(Mouse.Hit.X,Humanoid.RootPart.Position.Y,Mouse.Hit.Z)), 0.1 * DeltaTime)
end
Thr regular shiftlock instantly sets the cframe meaning lerping wouldn’t work, i think crim uses a custom shiftlock script to be able to customize the movement amount
You would lerp the CFrame of this to whatever the default script sets the CFrame to. Keep in mind that you need to account for frame times, so make sure alpha is multiplied by the delta time.
I found short of a solution but it looks glitchy when i move
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()
if self.inFirstPerson or self.inMouseLockedMode then
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local Character = player.Character
local RootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local Camera = workspace.CurrentCamera
Humanoid.AutoRotate = false
local rx, ry, rz = Camera.CFrame:ToOrientation()
a1 = game:GetService("TweenService"):Create(RootPart, TweenInfo.new(0.09), {CFrame = CFrame.new(RootPart.CFrame.p) * CFrame.fromOrientation(0, ry, 0)})
a1:Play()
else
pcall(function()
a1:Cancel()
a1 = nil
end)
player.Character:WaitForChild("Humanoid").AutoRotate = true
UserGameSettings.RotationType = Enum.RotationType.MovementRelative
UserInputService.MouseBehavior = Enum.MouseBehavior.Default
end
end
end
I am going to mark this as solved in about 24 hours or less because nobody really knows a proper solution so If no proper response I will just go without shift lock sway inside of my game until I find out myself. Thanks to everyone that tried to help out.
if you really want it added I’d suggest disabling default shiftlock and make your own by setting cframe ever frame or using a body mover like BodyGyro or AlignedOrientation