Hey there! I was wondering if there was a better way to implement the code below. As you can see It doesn’t look too neat and It seems like it would hurt performance. Would there be a better way to imbed multiple keyframe signals?
Example of what currently have:
curAnim:GetMarkerReachedSignal("FirstSignal"):Connect(function()
-- DO STUFF
curAnim:GetMarkerReachedSignal("NextSignal"):Connect(function()
OtherAnim:Play()
-- DO MORE STUFF
end)
NextAnim:Play()
curAnim:GetMarkerReachedSignal("NextNextSignal"):Connect(function()
otherOAnim:Play()
end)
end)
bit confusing the way you’ve set this up but here we go
local Runner
Runner = function()
(curAnim:GetMarkerReachedSignal("NextSignal")):Once(function() -- These are all one-time listeners, they'll be GC'ed when called.
OtherAnim:Play();
end);
NextAnim:Play();
(curAnim:GetMarkerReachedSignal("NextNextSignal")):Once(function()
otherOAnim:Play();
-- I assume this signals a restart to the tree.
(curAnim:GetMarkerReachedSignal("FirstSignal")):Once(Runner)
end);
end
(curAnim:GetMarkerReachedSignal("FirstSignal")):Once(Runner); -- Connect using once, you can just re-hook this.
Alternatively, you could listen for curAnim’s looped event and re-attach the listener then.