So I have some code which tilts the players character in the direction they are walking in. It works perfectly in R15, however it doesn’t seem to function properly in R6 due to a limitation with joints.
This is the code (R15 version):
-- services
local runService = game:GetService("RunService")
-- variables
local humanoidRootPart = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local lowerTorso = script.Parent.Parent:WaitForChild("LowerTorso")
local upperTorso = script.Parent.Parent:WaitForChild("UpperTorso")
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local rootJoint = lowerTorso:WaitForChild("Root")
local waistJoint = upperTorso:WaitForChild("Waist")
local originalRootJointC0 = rootJoint.C0
local originalWaistJointC0 = waistJoint.C0
local rotationSpeed = 8
local rotationAmount = 0.3
-- functions
runService.RenderStepped:Connect(function(deltaTime: number)
local direction = humanoidRootPart.CFrame:VectorToObjectSpace(humanoid.MoveDirection)
rootJoint.C0 = rootJoint.C0:Lerp(originalRootJointC0 * CFrame.Angles(0, 0, -(direction.X * rotationAmount)), deltaTime * rotationSpeed)
waistJoint.C0 = waistJoint.C0:Lerp(originalWaistJointC0 * CFrame.Angles(0, 0, -(direction.X * rotationAmount)), deltaTime * rotationSpeed)
end)
And this is the R6 version (The one which doesn’t properly work):
-- services
local runService = game:GetService("RunService")
-- variables
local humanoidRootPart = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local rootJoint = humanoidRootPart:WaitForChild("RootJoint")
local originalRootJointC0 = rootJoint.C0
local rotationSpeed = 8
local rotationAmount = 0.3
-- functions
runService.RenderStepped:Connect(function(deltaTime: number)
local direction = humanoidRootPart.CFrame:VectorToObjectSpace(humanoid.MoveDirection)
rootJoint.C0 = rootJoint.C0:Lerp(originalRootJointC0 * CFrame.Angles(0, 0, -(direction.X * rotationAmount)), deltaTime * rotationSpeed)
end)
I have no idea how to properly make this work. I’ve searched for a bit on the devforum but to no avail. I also tried to mess around with some properties/methods but again to no avail. Any help would be greatly appreciated. Thanks