I’ve permanently borrowed some code from an EgoMoose tutorial a while back on characters looking up and down. It involved changing the C0 of some motors every frame to move the torso and head. However, with the (annoying) new changes with the animation engine, trying to move the arms and head makes the animation look wrong.
Here’s the current code using C0. I think I have to start using Motor6D.Transform, but I have no idea how.
RS.RenderStepped:Connect(function()
if not char:GetAttribute("DisableLook") then
neck.C0 = neckC0 * CFrame.fromEulerAnglesYXZ(camera.CFrame.LookVector.Y*0, 0, 0);
end
if char:GetAttribute("DisableTorso") and camera.CFrame.LookVector.Y > 0 or not char:GetAttribute("DisableTorso") then
waist.C0 = waistC0 * CFrame.fromEulerAnglesYXZ(camera.CFrame.LookVector.Y*1, 0, 0);
elseif char:GetAttribute("DisableTorso") and camera.CFrame.LookVector.Y <= 0 then
waist.C0 = waistC0 * CFrame.fromEulerAnglesYXZ(0, 0, 0);
end
end)
Since you’re going to be changing the Motor6D.Transform, all you really need is the offset of the Motor6D’s C0. The offset of a Motor6D, in general, is going to be:
Now, it’s important to note that Motor6D.Transform is updated if there is an AnimationTrack playing. To add offset to the current animation playing, you need to add an offset to the Motor6D.Transform on RunService.Stepped.
local neckTransformOffset = CFrame.fromEulerAnglesYXZ(0, 0, 0)
local waistTransformOffset = CFrame.fromEulerAnglesYXZ(0, 0, 0)
-- this should constantly update the offsets
RunService.RenderStepped:Connect(function()
if not char:GetAttribute("DisableLook") then
neckTransformOffset = CFrame.fromEulerAnglesYXZ(camera.CFrame.LookVector.Y*0, 0, 0);
end
if char:GetAttribute("DisableTorso") and camera.CFrame.LookVector.Y > 0 or not char:GetAttribute("DisableTorso") then
waistTransformOffset = CFrame.fromEulerAnglesYXZ(camera.CFrame.LookVector.Y*1, 0, 0);
elseif char:GetAttribute("DisableTorso") and camera.CFrame.LookVector.Y <= 0 then
waistTransformOffset = CFrame.fromEulerAnglesYXZ(0, 0, 0)
end
end)
-- this should update the Motor6D Transforms
RunService.Stepped:Connect(function()
if neck then
neck.Transform *= neckTransformOffset
end
if waist then
waist.Transform *= waistTransformOffset
end
end)