RootJoint tilt isn't smooth

I have a “Tilt animation” script for my character in my game, and It works nice, but when the character stops, the RootJoint takes some time to get back to normal instead of being a smooth transition.

This is the code that I’m using for the tilt:

Velocity = Hrp.Velocity

if Velocity.Magnitude > 30 then
	Direction = Velocity.Unit
	Angle = Hrp.CFrame.RightVector:Dot(Direction)/math.pi
	
	local TiltTweenInfo = TweenInfo.new(.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
    local TiltTween = TweenService:Create(Hrp.RootJoint, TiltTweenInfo, {C0 = DefaultRootC0 * CFrame.Angles(0, -Angle, 0)}):Play()
else
	local TiltTweenInfo = TweenInfo.new(.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
    local TiltTween = TweenService:Create(Hrp.RootJoint, TiltTweenInfo, {C0 = DefaultRootC0}):Play()
end 

The code is running into a Script that fires a function on RunService.Heartbeat.

3 Likes