Is it possible to preloadAsync()
animations that are stored in an animations module table as string IDs? This is my current setup, but I’m experiencing an issue where the first play is delayed. Must it be an instance that is passed to preloadAsync()
? If so, what is the best way to modify my system? I have many different weapons, each utilizing their own animations, and some sharing animations, currently I directly use humanoid:LoadAnimation(stringid)
from the weapon data module
The first problem I’m having with understanding this is how are you even using loadanimation without creating an animation instance, but anyway, preloadAsync()
cannot be called on animation ids, instead load them like this, then play when you need them as they’ll be loaded:
local table = {"542532432","341233245"} --this is your table, i just put random numbers
local humanoid = PATHTOYOURHUMANOID
task.wait(2) --for the stuff to load
for i,v in ipairs(table) do
local animationinstance = Instance.new("Animation",script)
animationinstance.AnimationId = tonumber(v)
local loadanimation = humanoid.Animator:LoadAnimation(animationinstance)
game.Debris:AddItem(animationinstance,1)
end
Yes my bad, I should have mentioned I am using an animation instance but I’m creating it as the user uses it, so preloading isnt really viable there
That’s the issue, you should never load them as the player uses because the first time they use it it’ll have a delay between loading it and playing it. Instead when they get a gun, load the animations used for it on their character, and play it when needed.
Just store all your animations for an example in one folder in ReplicatedStorage and preload them when they join the game
Or instead of loading it to the animator do preloadAsync()
on the ANIMATION FILE. Or as how Nicholas said it, you can do CP:PreloadAsync(folder:GetChildren())
Honestly after thinking about it, i think you should do something like this:
Don’t touch or change the way your system works if you feel like it.
Instead create a folder in ReplicatedStorage that includes all of the animations used by the system, and then just make a script preload all of the animations in that folder.
It doesn’t really matter if your system is using those Anim Instances in ReplicatedStorage since they will already be cached somewhere (So when you play the animation for the first time it won’t have any delay)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.