https://i.gyazo.com/8591ed88752bd8f6a4d03bf10e860432.mp4
As you can see in this video, when leaning, the player moves around the HumanoidRootPart’s axis. Is there any way to make the torso the center of all movement?
https://i.gyazo.com/691c25be7d98451481c378e89c300cb4.mp4
In the second video, I am pressing only W and S nothing else, and you can see it is not really smooth and choppy.
Code:
if key == "ActiveLean" then
local RootJoint = self.RootPart:FindFirstChild("RootJoint")
local RH = self.RootPart.Parent.Torso:FindFirstChild("Right Hip")
local LH = self.RootPart.Parent.Torso:FindFirstChild("Left Hip")
local Info = TweenInfo.new(.3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local RP = self.RootPart.Position
if Value == 1 then
self.CameraOffset = Vector3.new(1.25, self.CameraOffset.Y, self.CameraOffset.Z)
TweenService:Create(RootJoint, Info, {C1 = CFrame.new(-1,-0,0) * CFrame.Angles(math.rad(-90),math.rad(-15),math.rad(-180))} ):Play()
TweenService:Create(RH, Info, {C1 = CFrame.new(.5,1,0)* CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))} ):Play()
TweenService:Create(LH, Info, {C1 = CFrame.new(-.5,1,0)* CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))} ):Play()
elseif Value == -1 then
self.CameraOffset = Vector3.new(-1.25, self.CameraOffset.Y, self.CameraOffset.Z)
TweenService:Create(RootJoint, Info, {C1 = CFrame.new(1,0,0) * CFrame.Angles(math.rad(-90),math.rad(15),math.rad(180))} ):Play()
TweenService:Create(RH, Info, {C1 = CFrame.new(.5,1,0)* CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))} ):Play()
TweenService:Create(LH, Info, {C1 = CFrame.new(-.5,1,0)* CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))} ):Play()
elseif Value == 0 then
self.CameraOffset = Vector3.new(0, self.CameraOffset.Y, self.CameraOffset.Z)
TweenService:Create(RootJoint, Info, {C1 = CFrame.new(0,0,0)* CFrame.Angles(math.rad(-90),math.rad(0),math.rad(180))} ):Play()
TweenService:Create(RH, Info, {C1 = CFrame.new(.5,1,0)* CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))} ):Play()
TweenService:Create(LH, Info, {C1 = CFrame.new(-.5,1,0)* CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))} ):Play()
end
self.RootPart.CFrame = self.RootPart.CFrame * self.RootPartOffset
TweenService:Create(self.Character.Humanoid, Info, {CameraOffset = self.CameraOffset}):Play()
end