Live Animation Creator Command Line Optimization Functions (Reduce Keyframes, Looping Forward Reverse, Position Correction)

So I have begun using the Live Animation Creator in the Animation editor.
It’s great and all but there are some issues that I have created solutions for that I would like to share.

Optimizing Keyframes
You may notice sometimes the animations created by the live animation creator are jittery. This can be cause by too many keyframes and thus be solved by running this code in the command line replacing magusartstudios with the name of your animation directory! Make sure to make a copy of your animations since running code in the command line does not work with the undo button!

local animationfolder="Magus_ArtStudios2"
local animation={} 
for i,v in game.ServerStorage.RBX_ANIMSAVES[animationfolder]:GetChildren() do
 local animations=v:GetChildren() 
table.sort(animations,function(a,b) if a.ClassName=="Keyframe" and b.ClassName=="Keyframe" then return a.Time>b.Time else return false end end) 
local everyother=0
 for t,o in animations do 
if o:IsA("Keyframe") then
 if everyother==0 then everyother=1 
else everyother=0 o:Destroy() end
 end 
end 
end 

Next is sometimes correcting the position of the animations. This is another option for when your avatar in the animation is moving around and you would like it to not move around. This function respects the y position of the animation and zeros out the x and z positions.

for i,v in game.ServerStorage.RBX_ANIMSAVES:GetDescendants() do if v:IsA("Pose") then v.CFrame=v.CFrame-Vector3.new(v.CFrame.Position.X,0,v.CFrame.Position.Z) end end 

image

That is all for now. Hope that helps! I will be referencing this in the future myself.

image

local animation={} for i,v in game.ServerStorage.RBX_ANIMSAVES.Magus_ArtStudios2:GetChildren() do v.Name..=" opt"  end 

To run code in the command line type or paste it into the bottom here.


.

EDIT:
Perfectly Looping Animations Forward then Reverse
Finally, I have written this function which adds a reversed animation to the end of the animations allowing you to create perfectly looping animations!

local animation={} 
for i,v in game.ServerStorage.RBX_ANIMSAVES.Magus_ArtStudios2:GetChildren() do
 local animations=v:GetChildren() 
local highest=v.End.Time 
table.sort(animations,function(a,b) 
if a.ClassName=="Keyframe" and b.ClassName=="Keyframe" then 
return a.Time<b.Time
 else 
return false end end) 
v.End.Name="Keyframe" 
for t,o in animations do 
 if o:IsA("Keyframe") then
 local reversed=o:Clone() 
reversed.Time=highest+(highest-reversed.Time)
 if t==1 then reversed.Name="End"
 end
reversed.Parent=v
 end end end

With that this resource is complete!


.

2 Likes