im currently stumped on making the players torso lean into the humanoids move direction
ive tried using bodygyro, motor6d.Transform, motor6d.C0 and none of them worked
heres some of the failed code with bodygyro:
(this is all on r6)
while true do
wait()
if hum.MoveDirection.Magnitude > 0 then
local dir = (torso.Position - hum.MoveDirection).unit
local look = torso.CFrame.lookVector
gyrostuff.CFrame = CFrame.new(torso.Position, torso.Position + dir)
print(hum.MoveDirection)
end
end
edit: Ok I don’t think I actually fixed it, it lerps really really slowly with over 60 fps, I forgot how to do the formula for lerping with delta time.
Well, that’s what you asked for. If you want to tilt only when walking sideways then you can revert the -MoveDirection.X * MaxTiltAngle back to the original (without the math.max)
Lol, I didn’t saw it at first and changed his script for r15 by myself
local RunService = game:GetService'RunService'
local Players = game:GetService'Players'
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass'Humanoid'
local RootPart = Character:WaitForChild'HumanoidRootPart'
local RootJoint = Character.LowerTorso:WaitForChild'Root' --I changed to root joint
local RootC0 = RootJoint.C0
local MaxTiltAngle = -10 --and made it negative
local Tilt = CFrame.new()
RunService.RenderStepped:Connect(function(Delta)
local MoveDirection = RootPart.CFrame:VectorToObjectSpace(Humanoid.MoveDirection)
Tilt = Tilt:Lerp(CFrame.Angles(math.rad(-MoveDirection.Z) * MaxTiltAngle, math.rad(-MoveDirection.X) * MaxTiltAngle, 0), 0.2 ^ (1 / (Delta * 60)))
RootJoint.C0 = RootC0 * Tilt
end)