Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Anyone mind explaining this code from the wiki in detail and how it would be used?

Asked by
crome60 43
6 years ago
local function getJointBetween(part0, part1)
    for _, obj in pairs(part1:GetChildren()) do
        if obj:IsA("Motor6D") and obj.Part0 == part0 then
            return obj
        end
    end
    for _, obj in pairs(part0:GetChildren()) do
        if obj:IsA("Motor6D") and obj.Part1 == part1 then
            return obj
        end
    end
end

local function applyKeyFrame(rig, poseKeyframe) 
    local function recurApplyPoses(parentPose, poseObject)
        if parentPose then
            if rig:FindFirstChild(parentPose.Name) and rig:FindFirstChild(poseObject.Name) then
                local joint = getJointBetween(rig[parentPose.Name], rig[poseObject.Name])
                if joint then
                    joint.C1 = joint.C1 * poseObject.CFrame:inverse()
                end
            end
        end
        for _, subPose in pairs(poseObject:GetSubPoses()) do
            recurApplyPoses(poseObject, subPose)
        end
    end
    for _, poseObj in pairs(poseKeyframe:GetPoses()) do
        recurApplyPoses(nil, poseObj)
    end
end

From: http://wiki.roblox.com/index.php?title=API:Class/Keyframe

From what I understand, its supposed to convert animations created with the animation editor to CFrames that can be applied to a rig, is this correct? If not, what does it do and how do I use it?

Answer this question