So I basically have a current System for game that tilts the upper body to a position, in this case, my game is a TD game, where I want my Tower’s Upper Body to face at the HRP position of the mob
(The Mob Could be Big and tower face Up, or be a small mob and the Tower’s Upper Body will face down)
Currently I’m using @dthecoolest Mouse Upper Body Follow function, but a little bit modified by me, This is my Version:
local function RotateTorsoR6(Model: Model , Target: Model)
local TargetHRP = Target:FindFirstChild("HumanoidRootPart")
local Head = Model:FindFirstChild("Head")
local HumanoidRootPart = Model:FindFirstChild("HumanoidRootPart")
local Torso = Model:FindFirstChild("Torso")
local HeadMoter6D = Torso:FindFirstChild("Head")
local Waist = HumanoidRootPart:FindFirstChild("Torso")
---- Dont Add this, I only added this Because I contain my Legs Moter6D's in This Part
local TorsoAnchor = Model:FindFirstChild("MoverThing")
---- For you, It should be this:
---- local RHip = Torso:FindFirstChild("Right Leg") ---- Or Probably: Torso:FindFirstChild( "Right Hip" )
---- local LHip = Torso:FindFirstChild("Left Leg") ---- Or Probably: Torso:FindFirstChild( "Left Hip" )
local RHip = TorsoAnchor:FindFirstChild("Right Leg")
local LHip = TorsoAnchor:FindFirstChild("Left Leg")
local LHipOriginC0_Moter = LHip.C0
local RHipOriginC0_Moter = RHip.C0
local NECK_ORIGIN_C0 = HeadMoter6D.C0
local WAIST_ORIGIN_C0 = Waist.C0
HeadMoter6D.MaxVelocity = 1/3
if Head and Torso then
local TorsoLookVector = Torso.CFrame.lookVector
local HeadPosition = Head.CFrame.p
local TargetFace = TargetHRP.Position
local DIS = (Head.CFrame.p - TargetFace).magnitude
local DIF = Head.CFrame.Y - TargetFace.Y
local NeckGoal = CFrame.Angles(-(math.atan(DIF / DIS) * 0.5), (((HeadPosition - TargetFace).Unit):Cross(TorsoLookVector)).Y * 1, 0)
HeadMoter6D.C0 = HeadMoter6D.C0:lerp(NeckGoal * NECK_ORIGIN_C0, 1).Rotation + NECK_ORIGIN_C0.Position
local xAxisWaistRotation = -(math.atan(DIF / DIS) * 0.5)
local yAxisWaistRotation = (((HeadPosition - TargetFace).Unit):Cross(TorsoLookVector)).Y * 0.5
local rotationWaistCFrame = CFrame.Angles(xAxisWaistRotation, yAxisWaistRotation, 0)
local goalWaistCFrame = rotationWaistCFrame * WAIST_ORIGIN_C0
Waist.C0 = Waist.C0:lerp(goalWaistCFrame, 1).Rotation + WAIST_ORIGIN_C0.Position
local currentLegCounterCFrame = Waist.C0*WAIST_ORIGIN_C0:Inverse()
local legsCounterCFrame = currentLegCounterCFrame:Inverse()
RHip.C0 = legsCounterCFrame*RHipOriginC0_Moter
LHip.C0 = legsCounterCFrame*LHipOriginC0_Moter
end
end
This Function fires every time It detects a mob, and when it does it does this function, but it works, it faces the tall mob during its first shot, but whenever the tower keeps shooting at this mob it just makes the upperbody tilt down and down each time:
I don’t know the cause for this, but any help would be appreciated, I’ve been trying to find a solution for hours now, but I couldn’t, im also not good at math so its impossible for me to make a new system from scratch.