Does :LoadAnimation cache up returned track

I need to know if roblox caches up the tracks that are returned by :LoadAnimation
For example if i were to do this:

for i=1, 100 do
	Animator:LoadAnimation(script.Animation)
end

Would it create 100 new tracks or only 1 on first cycle and then keep returning it from memory?

2nd question is IF the animation tracks gets cached up do they replicate over from client to server and vice versa? So for example I could :LoadAnimation on client which would create a new track linked to the Animator object, then do the same on server buet instead it would return already existing track from the client.

^ This would make animation handling so much easier if it’s true

Well if you’re not storing the AnimationTrack anywhere or do not interact with it (use functions etc) it should automatically being cleaned by script garbage cleaner

If you meant RemoteEvent / RemoteFunction replication, you can only send it in RemoteFunctions as instance.

If you meant could the AnimtionTrack loaded & played on client, yes, you actually can.

1 Like

Why don’t you use an animation handler module that caches it and replicates it?

AnimationTracks don’t get automatically cleaned up when its not in use. They’re loaded in the animator until it’s manually destroyed with :Destroy(). AnimationTrack also have a limit of 256 tracks for one Animator, and if it’s reached the animator won’t play any more animations so it’s important to destroy tracks that aren’t used anymore

example:

local animationTrack = Animator:LoadAnimation(script.Animation)

--plays animation and yields until finished playing
animationTrack:Play()
animationTrack.Ended:Wait()

--destroys track
animationTrack:Destroy()
animationTrack = nil

@Roldstred

1 Like

I’ve been using one, just snapped what if roblox already handles all of this and I’m using a wrapper for nothing, had to make sure

Loaded animations would likely get gcd as soon as theyre not scoped anymore

Roblox does not cache tracks automatically, you have to cache them yourself

Well they do get automatically cleaned atleast if they don’t have any references, If you play an animation and then try to :LoadAnimation it from other script and stop then it wont do nothing because tracks aren’t the same. Some people also told me :LoadAnimation always creates a new track but animation itself gets cached

2 Likes

Not really.
That would mean change behavior of animations (aged really badly khm khm animation blending) aswell as hit on perfomance and removal of customization.

Yeah, it always creates a new track. You need to remember to manually clean them up

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.