Motor6D manipulation to make the torso face the mouse is messing with the roblox animation using that Motor6D

While digging for a way for the torso to follow the mouse, I found this from a year or two ago:

Distance = (Head.CFrame.p - Point).magnitude
Difference = Head.CFrame.Y - Point.Y
Waist.C0 = Waist.C0:lerp(currentC0 * CFrame.Angles(-(math.atan(Difference / Distance)), (((Torso.CFrame.p - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 1.5 / 2)

It works fine on its own, but when you use an animation that manipulates the uppertorso (which I’m assuming uses the Waist.C0 also) it sorts of glitches the animation.

Here it is without UpperTorso animations:

Result (ignore the animation when it fires because that was the hacky solution I tried):


This is when you manipulate the uppertorso to face the centre(so the left arm can reach the gun’s barrel):

instead of rotating the torso as is in the animation, it sorts of does an in between of the c0 manipulation and the animation:

Before, I fixed this by just rotating the animation all the way to where it accounts for the C0 CFrame manipulation like so:

Result:

The problem with this hacky solution is that if you had general purpose animations like crouching or sprinting where there would be no weapon and thus no uppertorso animation to account for. If I use the same hacky solution again, I’d have to make a copy of the animation for each weapon to account for that weapon’s upper torso animations.

I tried Motor6D.Transform but that just does the same thing as C0.
I need something like the last example but without having to manually account for the weapon animation’s rotation.

try this
put this in the loop where it rotates the uppertorso

local function checkIfPlaying()
     if #myHumanoid:GetPlayingAnimationTracks() == 0 then return end
     for _, v in pairs(myHumanoid:GetPlayingAnimationTracks()) do
           if v.Name == "ShootingAnimation" then
               return true
            end
       end
end

while rstep:Wait() do
if not checkIfPlaying() then
Waist.C0 = Waist.C0:lerp(currentC0 * CFrame.Angles(-(math.atan(Difference / Distance)), (((Torso.CFrame.p - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 1.5 / 2)
end
end

I don’t want to disable the torso following the mouse because then you’d have situations where you’re right next to an enemy and the gun would point to the side of the enemy rather than at the enemy.

Just looking for a way to merge the first and last example that I provided to where it rotates the uppertorso like there was no animation present while still keeping the rotation of the uppertorso in the animation so that the left arm can grab the weapon’s barrel.

Also, your solution would be expensive to do this every Heartbeat, wouldn’t it?

So uhm, I don’t know what exactly what the change was since I’m terrible with CFrames and math in general but it was fixed by switching from Torso.CFrame.p to Head.CFrame.p

and torso look vector to head look vector.

Still got no clue what most of these math operations like :Cross().Y and math.atan do to make the rotation and the limit for the rotation work, along with why you make the Y angle negative and the X angle positive.

Also, anyone got a clue what’s different between Motor6D.Transform and Motor6D.C0? The only difference I found was that Motor6D.Transform only worked when using Stepped, while Motor6D.C0 can be changed in Heartbeat and RenderStepped too.
-shrug emote-