animation has like 1 in 20 to not call the event key as well as .DidLoop.
local f = script.Parent.AnimationController.Animator:LoadAnimation(script.f)
local b = script.Parent.AnimationController.Animator:LoadAnimation(script.b)
local l = script.Parent.AnimationController.Animator:LoadAnimation(script.l)
local r = script.Parent.AnimationController.Animator:LoadAnimation(script.r)
local currentAnim = nil
local pos
local hipBone = script.Parent.RootPart["mixamorig:Hips"]
local spineBone = script.Parent.RootPart["mixamorig:Hips"]["mixamorig:Spine"]
function playAnim(anim)
local a = 0
if currentAnim == nil then
currentAnim = anim
anim:Play(0)
elseif currentAnim ~= anim then
a = currentAnim.TimePosition
currentAnim:Stop()
currentAnim = anim
anim:Play(0,1,0)
anim.TimePosition = a
anim:Play(0,1,1)
end
currentAnim:GetMarkerReachedSignal("endKey"):Connect(function()
pos = Vector3.new(spineBone.WorldPosition.X,hipBone.WorldPosition.Y,spineBone.WorldPosition.Z)
end)
currentAnim.Stopped:Connect(function()
pos = Vector3.new(spineBone.WorldPosition.X,hipBone.WorldPosition.Y,spineBone.WorldPosition.Z)
end)
currentAnim.DidLoop:connect(function()
hipBone.WorldPosition = pos
end)
end
while wait(3) do
playAnim(f)
wait(3)
playAnim(l)
wait(3)
playAnim(b)
wait(3)
playAnim(r)
end
it happenes on heavy models with a lot of bones usually from character creation. While mixamo somehow seems to work great.
Edit: found out the bug happens when an event is being hit very fast(fast animation)