Unloading AnimationTracks from Animators

Is there a way to unload AnimationTracks from Animators?

I am asking because my game is based on All-Star Cheerleading, and will have a lot of animations. I load the animations and put the tracks in a table.

The way I want it to work is selecting a skill type (e.g tumbling, stunting, jumps), and then the UI comes up with a list of all the skills and loads the animations so that when you press the button for that skill, it plays.
If you then switch skill type, it would unload all the animations on the animator and then load all the new ones of that skill type.

I’d just like to know if that’s possible :slight_smile:

EDIT if not clear:
I just want to know if I can take an Animation TRACK and unload it.
You load it by doing
local track = Animator:LoadAnimation(AnimationObj)

I am wanting to know if deleting the track counts as unloading it from the Animator, as you can only have a maximum of 256 animations loaded onto an animator at once, and I will need more, so I need to unload tracks.

1 Like

Well, there’s Animator:GetPlayingAnimationTracks() which returns an array of tracks that are currently playing on the animator.

1 Like

I don’t need the tracks that are currently playing, I need to know if there’s a way to “Unload” the tracks that are loaded on the animator

1 Like

Well I think that’s the closest you can get.

1 Like

just destroy the animation when you don’t need it anymore with :Destroy()

1 Like

I need the animation object in future to reload the tracks, I’m asking if I can delete or unload animation tracks from an animator.

1 Like

So you want an already finished animation (whoch you uploaded) To be back to the unpublished state which you could then edit? Thats not possible I think.

1 Like

AFAIK you can delete the animation track object, not the animation object

1 Like

No? I want to be able to take an animation track -
local track = Animator:LoadAnimation(AnimationObj)

and then unload the track when I need to, I am unsure if deleting it counts as unloading it.

1 Like

Okay I just wanted to check if deleting the track is the same as unloading it lol thanks!

2 Likes

Oh why didn’t you say so earlier then I would’ve understood, you can clone the track and parent it in somewhere like repstorage/serverstorage, which gives it the illusion of being “destroyed”, then when you need it get it from repstorage.

1 Like

You can’t clone a track it’s not an in game object

1 Like

You can’t? My life is a lie.

30char

1 Like

Actually no wait you can, I just checked on studio my life isn’t a lie.

1 Like

You are thinking of an Animation Object - all that does is hold the animation Id. I am talking about a track

local track = Animator:LoadAnimation(AnimationObject)

this loads it onto the animator, I wanted to know if there was a way to unload it

3 Likes

Yes I am saying you can clone the track.

1 Like

Cloning it doesn’t unload the track from the animator tho… it just makes a new track

1 Like

Well yeah but that’s the closest you can do, because like you said you wanna use those tracks in the future. You can clone that track and then load the cloned one later.

Sort of like how people bring back a part to life, they hide it in repstorage/servstorage, and then they put it back in wrokspace. Not actually destroyed, an illusion.

1 Like

I don’t think you’re understanding my problem.

There are a maximum of 256 tracks allowed to be loaded on an animator at once. My game will have a lot more than 256 animations, hence I want to be able to unload and load tracks at will.

You cannot clone and move a track to ServerStorage because it isn’t an in-game instance. It is just a variable in a script. And even if I could do that, it would not solve my issue because that “cloned” track is still LOADED onto the animator.

3 Likes

Yeah I just looked back and realised I was talking gibberish, english still isn’t my first language but i’m taking lessons to sorta understand it. I hope I’m making sense right now.

But yeah you can’t clone the tracks I realised, but you can destroy them

I think the “unloading” word got me confused, if you were just asking how to destroy them I wouldn’t have gotten confused.

But by the way “:Destroy()” is deprecated, instead use debris service to destroy the instance effectively:

local Debris = game:GetService("Debris")

Debris:AddItem(track, 0)