Hi
I want to use bone.Transform
to move the bone towards a CFrame location in world space.
Attached is a file that correctly does this for a non-nested bone hierarchy:
bone_transform_test.rbxl (54.1 KB)
This uses the following code:
local part = workspace.Part
local attachment = part:FindFirstChildOfClass("Bone")
local targetPart = workspace.TargetPart
local attachmentWorldCFrame = attachment.WorldCFrame
local targetWorldCFrame = targetPart.CFrame
local relativeCFrame = attachment.Parent.CFrame:inverse() * targetWorldCFrame
attachment.Transform = relativeCFrame
However, this breaks for a nested bone hierarchy. I assume that is due to multiple offsets being inherited from parents while the code only accounts for the direct parent offset.
This is the result I get (see the rbxl file):
TLDR: I want to replace bone.WorldCFrame = targetCFrame
to bone.Transform = ...
so that the bone ends up at ‘targetCFrame’ (same result for both calls).
Thanks for your help.