Apologies if the title isn’t the best.
For my game’s aiming system, I want to make the player’s arms aim towards wherever their cursor hits, similar to Guts & Blackpowder. I have achieved this exact effect using a custom rig, but that is unsatisfactory because most gears don’t work with it and I have to manually recode them.
Essentially, it simulates the shoulder Motor6Ds in the torso staying with the HumanoidRootPart rather than the torso, and rotating them relative to that. I wish to instead replicate this with a default R6 rig.
I’ve been trying to accomplish this on & off for the past few days and each time, I keep going until I burn out and can’t make sense of it anymore. I think what I have so far could be some kind of step in the right direction, but I’m too checked out to really tell. CFrames overwhelm me easily.
RuS:BindToRenderStep("AimConnection", 1, function()
local aX, aY, _ = CFrame.new(head.Position, GetMouseHit().Position):ToEulerAnglesYXZ() --get mouse aim rotation
local _, tY, _ = torso.CFrame:ToEulerAnglesYXZ() --torso Y rotation
local _, rY, _ = rootPart.CFrame:ToEulerAnglesYXZ() --rootpart Y rotation
local torsoWorldC0 = torso.CFrame:ToWorldSpace(torso["Right Shoulder"].C0) --get shoulder C0 in world cframe
local worldC0 = rootPart.CFrame:ToWorldSpace(torso["Right Shoulder"].C0) --get shoulder C0 relative to rootpart instead of torso in world cframe
local aimWorldC0 = worldC0 * CFrame.Angles(0, 0, aX) --apply aim relative to rootpart
local aimTorsoWorldC0 = CFrame.new(torsoWorldC0.Position) * CFrame.Angles(aimWorldC0:ToEulerAnglesYXZ()) --idk
game.Workspace.Test.WorldCFrame = aimWorldC0 --attachment for testing
game.Workspace.Test1.WorldCFrame = aimTorsoWorldC0 --attachment for testing
torso["Right Shoulder"].C0 = CFrame.new(torso["Right Shoulder"].C0.Position) * CFrame.Angles(0, math.rad(90), aX) --apply to motor6d
rootPart.CFrame = rootPart.CFrame:Lerp(CFrame.new(rootPart.Position) * CFrame.Angles(0, aY, 0), 0.1) --turn character
end)
I’ve tried looking at many forum posts but none of them are really what I’m looking for. They’re either EXACTLY the same query I’m having with no helpful answers, or CFrame questions that are almost what I’m looking for. However, if there is a post out there that perfectly answers my question, then please post it, as I may have somehow missed or misunderstood it. Thanks in advance.