How do i make the Upper animation Not be affected by lower animation rotation

I have 2 animations. one walking(Full body) and other is aiming from upper torso and above, which is the head and both arms and hands.
The walking animation is in Core priority.
The aiming is Action2 Priority.

When i play these 2 animations the Upper body is rotating relatively to where the lower torso points it which is what i dont want to, I want to keep the rotation of the Upper body the same it is as the animation.
Sadly this is what i get


I want the upper torso to rotate exactly where the animation tells it to rotate and not relative to lower body animation with lower priority.
this is the pose of lower body animation
Capture

youre probably going to have to make the aiming control the lower torso

I thought about that before but that would wack my lower body animation as the lower torso dictates the direction of the legs. in other words if the lower torso stays on same rotation the legs will walk in wrong direction

Most games work that way. You probably just didn’t notice because it’s not very noticeable, haha. But yeah, scripting it is the only real way to get this to work. I had a game where I did this, trying to find it right now to show you what it looks like

So how am i suppose to do that? i dont see anyone posted something about that here

It’s really wonkey because roblox isn’t meant to work that way from the ground up. If you just try to naively rotate the motor6d, your legs get all bend the wrong way. Easiest way to implement it would be to have your character have invisible legs and an invisible lower torso, and have a secondary rig on top that does the opposite which then gets rotated. But you’ll have to replicate that manually, which is yet more work just to get this one slight polish in.

Generally speaking, it’s more of a headache than worth.

You probably need to use the .Transform CFrame of the motor6d and perhaps even :Inverse() the CFrame of the lower body animation to cancel it out in a complicated formula.

I am busy at work and also have no idea what exactly you want so I would recommend you mess around the formulas in .Presimulation somehow.

You should also consider the motor6d formula part0c0transform = part1*c1 which will help.

I did something similar with the legs for R6 yo avoid the torso effecting the leg animations.

I have no idea how the formula actually works I just piece it together like a monkey.

^ This doesn’t work as mentioned due it propagating invalid cframes down the chain and making the legs bend all wrong. Edit: Didn’t know you could do that
Finally found the gif, here’s what it looks like.
RobloxStudioBeta_lXyupmZxst

What are you trying to accomplish here exactly? are you trying to create strafing?

I have a walking animation that i DONT want it to affect the aiming animation(upper body) of the character. The Upper Torso should Aim towards the target while the lower animation is playing.

Check the link dthecoolest posted, there’s a code snippet you could probably use. You’d need to convert it to r15 though

Im confused how does it work. i did make the script which is:

self = script.Parent
local waist = self.UpperTorso.Waist
local waC0 = waist.Transform


local target = workspace:FindFirstChild("target")
local anim = self.Humanoid.Animator:LoadAnimation(script.Animation)
local RunService = game:GetService("RunService")
anim:Play(0,1,0.001)
anim.Priority = Enum.AnimationPriority.Action4
wait(1)
self.HumanoidRootPart.AlignOrientation.Enabled = true
function aim()
	self.HumanoidRootPart.AlignOrientation.CFrame = CFrame.new(self.HumanoidRootPart.Position,target.Position)
	local x1,y1,z1 = self.HumanoidRootPart.CFrame:ToOrientation()
	local x2,y2,z2 = self.LowerTorso.CFrame:ToOrientation()
	local direction = (target.Position - self.HumanoidRootPart.Position).unit
	local verticalAngle = math.deg(math.asin(direction.Y)) 
	
	waist.Transform = waC0 * CFrame.fromAxisAngle(
		script.Parent.LowerTorso.CFrame:toObjectSpace(self.HumanoidRootPart.CFrame).rightVector, 
		-x2-x1*(-z2-z1)) * CFrame.fromAxisAngle(
		script.Parent.LowerTorso.CFrame:toObjectSpace(self.HumanoidRootPart.CFrame).UpVector, 
		-y2+y1) * CFrame.fromAxisAngle(
		script.Parent.LowerTorso.CFrame:toObjectSpace(self.HumanoidRootPart.CFrame).LookVector, 
		-z2-z1*(-x2-x1)) * waist.Transform
	anim.TimePosition = (verticalAngle + 90) / 30
print(anim.TimePosition)
end
RunService.Stepped:Connect(aim)

Ok so @dthecoolest and @Kizylle. Hopefully that will explain it better. So i tried what dthecooleest code but that doesnt make the upper body or head or anything aim towards the target.

So first i added a very long red part that is masless and has no collisions, weldConstrainted it to head.

When i hit play, and used run animation. the red part did not follow the target as demonstrated in this video:

I want the red part to aim the target all the time, not only when it doesnt play animation

the code:

local RunService = game:GetService("RunService")
wait(2)
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()

local Camera = workspace.CurrentCamera

local Character = Player.Character or Player.CharacterAdded:Wait()
--Old R15 code
local Head = Character:WaitForChild("Head")
--local Neck = Head:WaitForChild("Neck")

--local Torso = Character:WaitForChild("UpperTorso")
--local Waist = Torso:WaitForChild("Waist")

--New R6 stuff
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local Torso = Character:WaitForChild("UpperTorso")
local Neck = Head:WaitForChild("Neck")

local Waist = Torso:WaitForChild("Waist")


local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0

Neck.MaxVelocity = 1/3

RunService.RenderStepped:Connect(function() 
	print(1)
	local CameraCFrame = Camera.CoordinateFrame

	if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
		local TorsoLookVector = Torso.CFrame.lookVector
		local HeadPosition = Head.CFrame.p

		if Neck and Waist then
			if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
				local Point = PlayerMouse.Hit.p

				local Distance = (Head.CFrame.p - Point).magnitude
				local Difference = Head.CFrame.Y - Point.Y
print(4)

				local goalNeckCFrame = CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)
				Neck.C0 = Neck.C0:lerp(goalNeckCFrame*NeckOriginC0, 0.5 / 2).Rotation + NeckOriginC0.Position

				local xAxisWaistRotation = -(math.atan(Difference / Distance) * 0.5)
				local yAxisWaistRotation = (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 0.5
				local rotationWaistCFrame = CFrame.Angles(xAxisWaistRotation, yAxisWaistRotation, 0)
				local goalWaistCFrame = rotationWaistCFrame*WaistOriginC0
				Waist.C0 = Waist.C0:lerp(goalWaistCFrame, 0.5 / 2).Rotation + WaistOriginC0.Position


				local currentLegCounterCFrame = Waist.C0*WaistOriginC0:Inverse()

				local legsCounterCFrame = currentLegCounterCFrame:Inverse()


			end
		end
	end	
end)

Ok so if I understand right, you want your head to face where the cursor is, correct? Because an IKControl would be a lot better for this than trying to counteract the lower torso. In fact, that’d pretty much be one of it’s intended uses.

IKControl is good but it has its flaws because my custom character arms are A-pose (35 degrees) and IKControl only works on i pose better because you can rotate the arm. all i wantto know is how to make the upperTorso/head or upper body animation not be affected by the lower body thing

I don’t think there’s a good way to achieve what you’re doing without IKControl since you’re basically trying to have animations play and not at the same time. The best way to do it would be to have none of your animations rotate the upper torso or head, that way you don’t have to try to fight against the offset introduced by animations. You’re likely gonna have to make a compromise somewhere if you really want this bit of polish in.

I checked laser tag, the default shooting template. Looks like they do some major workaround by making the lased gun as a different character while your character is invisible. well that might word well for the player but not for npcs
Capture

I believe that’s just so you can see your arms in 1st person since usually you go completely transparent.
Edit: Yeah there’s just nothing special going on to make you face where you’re aiming.
RobloxStudioBeta_fyN96J5fg9

again, not questioning what you want to do, just trying to understand it:

what is your goal with this system? the lower body animation playing is exclusively walking? if so, you can adjust the walking animation to the aiming, instead of the opposite, it’s what i referred to when i mentioned strafing.

the lower body won’t change the aiming, because the rotation of your model lookDirection would be controlled by the aiming itself, with whatever walking animation you have being adjusted based on that.

IIRC Roblox already has Strafing animations.

if you also want to keep the lowerTorso still while aiming, then yeah, you’d have to have a manual control of the 6D instead of using animations.

Interesting, So I decided to try the problem out and spend hours on it.

This is the best I could come up with from the same theory as the R6 canceling out the effect of animations of the previous motor6D and applying it only the neck joint.

It still shakes but not as much probably due to rotation caused by the change in the head position rather than the change in the head orientation. But I have no idea atm.

You can see all the formulas I tried out in the comments and my sanity dwindle.

local RunService = game:GetService("RunService")

local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()

local Camera = workspace.CurrentCamera

local Character = Player.Character or Player.CharacterAdded:Wait()
--Old R15 code
local Head = Character:WaitForChild("Head")
--local Neck = Head:WaitForChild("Neck")
-- Settings for the laser
local laserLength = 1000
local laserThickness = 0.5

-- Create the laser part
local laser = Instance.new("Part")
laser.Name = "Laser"
laser.Anchored = false
laser.Massless = true
laser.CanCollide = false
laser.CanQuery = false
laser.Material = Enum.Material.Neon
laser.BrickColor = BrickColor.new("Bright red")
laser.Size = Vector3.new(laserThickness, laserThickness, laserLength)

-- Calculate position and orientation
local headCFrame = Head.CFrame
local forward = headCFrame.LookVector
local laserCFrame = headCFrame + forward * (laserLength / 2 + 1) -- offset slightly forward
laser.CFrame = CFrame.new(laserCFrame.Position, laserCFrame.Position + forward)

-- Parent to workspace
laser.Parent = workspace

local weld = Instance.new("WeldConstraint")
weld.Part0 = Head
weld.Part1 = laser
weld.Parent = laser

--local Torso = Character:WaitForChild("UpperTorso")
--local Waist = Torso:WaitForChild("Waist")

--New R6 stuff
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local Torso = Character:WaitForChild("UpperTorso")
local Neck : Motor6D = Head:WaitForChild("Neck")

local Waist : Motor6D = Torso:WaitForChild("Waist")
local Root : Motor6D = Character:WaitForChild("LowerTorso"):WaitForChild("Root")


local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0

Neck.MaxVelocity = 1/3

--Part0.CFrame * C0 * Motor6D.Transform = part1.CFrame * C1 
--Part1.CFrame * C1 * Motor6D1.Transform = part2.CFrame * C2 
--subsitutee 1 into 2 for part1 CFrame
--Part0.CFrame * C0 * Motor6D.Transform*C1:Inverse() * C1 * Motor6D1.Transform = part2.CFrame * C2 
----Part0.CFrame * C0 * Motor6D.Transform * Motor6D1.Transform = part2.CFrame * C2 
local function worldCFrameRotationToC0ObjectSpace(motor6DJoint,worldCFrame)
	local part1CF = motor6DJoint.Part1.CFrame
	local part0 = motor6DJoint.Part0
	local c1Store = motor6DJoint.C1
	local c0Store = motor6DJoint.C0
	local relativeToPart0 = part0.CFrame:inverse() * worldCFrame * c1Store

	local goalC0CFrame = relativeToPart0

	return goalC0CFrame
end

RunService.PreSimulation:Connect(function() 
	local CameraCFrame = Camera.CoordinateFrame

	if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
		local TorsoLookVector = Torso.CFrame.lookVector
		local HeadPosition = Head.CFrame.p

		if Neck and Waist then
			if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
				local Point = PlayerMouse.Hit.p

				local Distance = (Head.CFrame.p - Point).magnitude
				local Difference = Head.CFrame.Y - Point.Y

				local goalNeckCFrame = CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0)
				
				--Root.Transform = CFrame.new()
				--Waist.Transform = CFrame.Angles(0,0,math.pi/4)
				--Neck.Transform = CFrame.new()
				
				local x,y,z = Waist.Transform:ToOrientation()
				local newWaist = CFrame.fromOrientation(x,0,z)
				local counterCFrame =( newWaist):Inverse()
				
				local x,y,z = Root.Transform:ToOrientation()
				local newWaist = CFrame.fromOrientation(x,0,z)
				local counterCFrame2 =( newWaist):Inverse()

				--local counterCFrame = CFrame.new()
				--local modifyGoal = goalNeckCFrame*Root.Transform:Inverse()*Waist.Transform:Inverse()*Neck.Transform:Inverse()
				local modifyGoal =counterCFrame2*counterCFrame*goalNeckCFrame*Neck.Transform:Inverse()
				--local modifyGoal = goalNeckCFrame*Neck.Transform:Inverse()

				--local modifyGoal = goalNeckCFrame * NeckOriginC0

				--local lerp = Neck.C0:lerp(modifyGoal, 1)
				Neck.C0 = (modifyGoal).Rotation + NeckOriginC0.Position
				
				--local xAxisWaistRotation = -(math.atan(Difference / Distance) * 0.5)
				--local yAxisWaistRotation = (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 0.5
				--local rotationWaistCFrame = CFrame.Angles(xAxisWaistRotation, yAxisWaistRotation, 0)
				--local goalWaistCFrame = rotationWaistCFrame*WaistOriginC0
				--Waist.C0 = Waist.C0:lerp(goalWaistCFrame, 0.5 / 2).Rotation + WaistOriginC0.Position



			end
		end
	end	
end)