Get CFrame from Animation ID possible?

Is it possible to get the CFrame of all animated parts of a model by just providing an animation ID?

I could load the animation, then save the current parts cframes, but it’s tedius work.

Is it possible to get keyframe information from an animation somehow?
Ex: humanoid:LoadAnimation(anm):GetKeyframe(1).LeftLeg.CFrame

6 Likes

Using KeyframeSquenceProvider:GetKeyframeSequenceAsync(animationID) you can obtain a KeyframeSequence which you can then call :GetKeyFrames() to obtain the Keyframes which you can call :GetPoses() on to get the Pose objects which are named after the parts they manipulate. Each pose may contain subposes obtained with :GetSubPoses(). Each pose doesn’t actually affect the part CFrames directly, but through Motor6D instances and each pose specifies a .CFrame that changes the Motor6D.Transform property. To find the CFrame of a part, you can use this equation:

PartParent.CFrame * CParent * Transform == PartChild.CFrame * Child

Which, if my matrix math is correct, means that the child’s CFrame is equal to:

PartChild.CFrame = PartParent.CFrame * CParent * Transform * Child:Inverse()

So yes, it is possible. But is it painful? Very.

17 Likes

This is Gold!
I just don’t understand what the PartChild, PartParent, CParent and Child is.
A motor has just Part0 and Part1, can you write your expression in such terms instead?

EDIT: Found it.

local PartParent = motor.Part0
local PartChild = motor.Part1
local CParent = motor.C0
local Child = motor.C1
local Transform = pose.CFrame

Altho PartParent and PartChild can switch if your PartChild is more directly connected to your rootjoint, but this should work in most cases.

8 Likes