Bodypart CFrame to Motor6D conversion

Hello,

I’m trying to convert CFrame movement into an animation.
Rotation works just fine, but when trying to make the character move freely inside the animation every body part just separates further and further.

Rotating body parts works just fine
ezgif-4-259afe839937
What happens when I add the Motor6D CFrame to the bodypart’s CFrame

I know this has something to do with the Motor6D.Transform property, but I can’t seem to understand how the .Transform property works. Is it relative to it’s parent part? And even so, how would I be able
to move inside the local space?

My goal is not to record movement from normal movement, instead record VR movement into an animation.

1 Like

For Motor6D: Part1.CFrame = Part0.CFrame * C0 * Transform * C1:Inverse()
Make sure to consider all of these CFrames in your script.

Pose.CFrame corresponds to Motor6D.Transform.

If this doesn’t answer your question, consider sharing your CFrame code so we can pin down the issue.

1 Like

Thank you, here is my script. I’ve tried your solution but the same error occurs, the body parts are separated, really far out.

local sort = {["HumanoidRootPart"] = {["LowerTorso"] = {["LeftUpperLeg"] = {["LeftLowerLeg"] = {"LeftFoot"}},["RightUpperLeg"] = {["RightLowerLeg"] = {"RightFoot"}},["UpperTorso"] = {"Head",["LeftUpperArm"] = {["LeftLowerArm"] = "LeftHand"},["RightUpperArm"] = {["RightLowerArm"] = {"RightHand"}}}}}}
local keepgoing = true
local objectoanimate = game.Workspace:WaitForChild("thoricelli")

script.Parent.MouseButton1Click:Connect(function()
keepgoing = true

local starttick = tick()
local lasttick = tick()
game:GetService("RunService").RenderStepped:Connect(function()
	if keepgoing == true then
	if tick()-lasttick > 0.1 then  --Every 0.1 seconds a Keyframe will be created
		local keyframe = Instance.new("Keyframe")
		keyframe.Parent = game.Workspace.TestFolder --The folder where I keep the keyframes to copy it into the animasaves
		keyframe.Time = tick()-starttick
		SavePosition(keyframe,sort,objectoanimate)
	end	
		else
		return
	end
	end)
end)


script.Parent.Parent.stop.MouseButton1Click:Connect(function()
	keepgoing = false
end)

function SavePosition(prev,tableposition,objectosavevalue)
	for i,v in pairs(tableposition) do
		local newinstance = Instance.new("Pose")
		if type(i) == "string" then
		newinstance.Name = i
		newinstance.Parent = prev
		for _,b in pairs(objectosavevalue:GetChildren()) do
			if b.Name == i then
				for _,u in pairs(b:GetChildren()) do
					if u:IsA("Motor6D") then --Get the Motor6D value of the bodypart
						newinstance.CFrame = u.Transform+(b.CFrame:ToObjectSpace(u.Transform).Position)
					end
				end
			end
		end
		else
			newinstance.Name = v
			newinstance.Parent = prev
			for _,b in pairs(objectosavevalue:GetChildren()) do
			if b.Name == v then
				for _,u in pairs(b:GetChildren()) do
					if u:IsA("Motor6D") then --Get the Motor6D value of the bodypart
						newinstance.CFrame = u.Transform
					end
				end
			end
		end
		end
		if type(v) == "table" then
			SavePosition(newinstance,v,objectosavevalue) --The current object is a table, so iterate trough it.
		else
			if v ~= newinstance.Name then
				local newwinstance = Instance.new("Pose")
				newwinstance.Name = v
				newwinstance.Parent = newinstance
				for _,b in pairs(objectosavevalue:GetChildren()) do
					if b.Name == v then
						for _,u in pairs(b:GetChildren()) do
							if u:IsA("Motor6D") then --Get the Motor6D value of the bodypart
								newwinstance.CFrame = u.Transform
							end
						end
					end
				end
			end
		end
	end
end

I think the problem here is that the animation editor uses the Motor6D value of every bodypart and sets it to the CFrame of the keyframe.

When recording the current Motor6D value of the player during the recording, does not include the position in the local space of that bodypart, since those are not handled by the Motor6D value, the walking animation uses Motor6D, movement is handled by the parts position itself.

So looking at the 2nd picture I sent, I tried to add the current Motor6D value to the current CFrame position in the local space and store it in the keyframe, which during the animation will play inside the Motor6D of that bodypart, and which is what I’m confused by.

How would I be able to move (not only rotate) the Motor6D driven bodypart without the body parts separating and going into oblivion, using the bodypart’s CFrame and Motor6D combined into one or just converting the CFrame to a Motor6D value outright

(Sorry for bumping an old post but I really need help)
Alright so quick update, I’ve gotten it to kinda “work”.


Here’s how I’m doing it, if anyone’s interested.
Formula
But once the character moves from the origin, they turn into the same mess as in the first picture, on my post. I’m still confused, and can’t come up with a solution, I’ve asked countless people, but to no avail.

I’ve updated the script to include the origin, from where the recording started, it calculates every single bodypart’s Motor6D (starting from the LowerTorso), so that the other connected bodyparts can be updated accordingly, but that still doesn’t fix it.

Please, if anyone knows what I’m doing wrong, do not hesitate to help me out here.
If someone needs the script to pin-point the issue or any other form of image/video, I can post it.