NPC Glitches Upon Changing the Playing Animation

Whenever I change the currently playing animation on a model, there is a split-second where the model returns to its default pose (in my case a t-pose).

This ruins animations and I am unable to find a way to fix this issue. I have noticed that after a while this issue stops, but in practice within my game “waiting it out” is not really a solution.

That being said, I thought the fact that it fixes itself over time was an indicator that the animation was just not loaded in, so I used ContentProvider service to pre-load all of my animations before hand. This changed nothing.

I also tried changing the animation priority and this seemed to make the issue worse.

It’s very possible this is just an issue with how I am handling the animations, but in my defense there is not a whole lot of documentation on how to properly handle animations, so if someone could just help me out. :sweat_smile::pray:

Code:


local CONTENT = game:GetService("ContentProvider")


local poseAnims = { -- My Animations
	92180798556668,
	15407448069,
	15869696445,
}

-- Pre-load animations
local preLoadedAnims = {}

for i, anim in poseAnims do
	local poseAnim = Instance.new("Animation")
	poseAnim.AnimationId = "rbxassetid://"..anim
	table.insert(preLoadedAnims, poseAnim)
end 
CONTENT:PreloadAsync(preLoadedAnims)

while task.wait() do
	
	for i, anim in preLoadedAnims do
		
		local person = workspace:WaitForChild("People"):WaitForChild("Kimi")

		local controller = person:WaitForChild("AnimationController").Animator
		
		-- Stop all anims first
		for i, playAnim in controller:GetPlayingAnimationTracks() do
			playAnim.Priority = Enum.AnimationPriority.Core
			playAnim:Stop()
		end
		
		-- Play pre loaded animation
		local standingTrack = controller:LoadAnimation(anim)
		standingTrack.Priority = Enum.AnimationPriority.Action
		standingTrack.Looped = true
		standingTrack:Play()
		
		task.wait(2)
		
	end
	
end

First off, the effect you have with the hair is nicely done. As to your issue: The default Animate script does something like: The split-second Idle pose may be from not linking the stop and play with a transition time variable?
I just modify the default animate script for my projects, but I’m a bit of a noob scripter. Hope my idea helps.

if (currentAnimTrack ~= nil) then
   		currentAnimTrack:Stop(transitionTime)
   		currentAnimTrack:Destroy()
   	end

   	currentAnimSpeed = 1.0
   
   	-- load it to the humanoid; get AnimationTrack
   	currentAnimTrack = humanoid:LoadAnimation(anim)
   	currentAnimTrack.Priority = Enum.AnimationPriority.Core
   	 
   	-- play the animation
   	currentAnimTrack:Play(transitionTime)