Keeping world position of object the same while welded to an object that can move independently

I’m stumped.
I have two accessories, accessory A and accessory B. Accessory B is welded to accessory A. Accessory A is welded to the head of the player’s character. Both of them have a blank c0, and a c1 which acts as the offset.

Now, say I wanted to change only accessory A’s C1, and keep accessory B’s world position the same while doing so. How would I go about doing this? There doesn’t seem like an easy way to do so. The method that I have devised involves getting the magnitude and direction between the two accessories world CFrame positions, and setting the C1 to that.

There are some issues. Rotating accessory A will cause accessory B to rotate with it as if they were grouped together. This behavior is unintended, as I only want accessory A to be rotating. Accessory B’s world position should stay the same. This issue has been slowly chipping away at my sanity for the past few days and I can’t figure out a way to fix it. Any help?

You can use this formula to work with c1 in world space. You will have to change the C1 in the appropriate order with accessory A first then B.

Part0.CFrame * C0 = part1.CFrame * C1
weld.Part1.CFrame:inverse() * weld.Part0.CFrame * weld.C0 = weld.C1
--Subsitute part1 with some goalCFrame, to make part1 go to goal target
goalCFrame:Inverse() * motor6DJoint.Part0.CFrame * motor6DJoint.C0

local function worldCFrameRotationToC1(motor6DJoint, worldCFrame)
	local part0 = motor6DJoint.Part0
	local c0Store = motor6DJoint.C0
			
	return worldCFrame:Inverse() * part0.CFrame * c0Store 
end

A section from my messily made tutorial.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.